Loading
[InstCombine] Require one-use intermediate binop in foldBinOpShiftWithShift (#194341)
foldBinOpShiftWithShift rewrites binop(shift(X,C) op Mask, shift(Y,C)) to binop(shift(X+Y,C), Mask). Both shifts are matched with m_OneUse, but the enclosing binop that wraps (shift(X,C), Mask) is not. When that binop has additional users the rewrite cannot eliminate the originals and only adds new instructions. The reproducer in the issue shows this: a shared base with several downstream consumers gets duplicated on each one, so the fold grows the IR instead of shrinking it. Wrap the outer m_c_BinOp in m_OneUse so the fold only fires when the binop can actually be replaced. Mirrors the one-use discipline already applied to both shifts in the same matcher. Fixes #194007.