Fold
binop(shift(ShiftedC1, ShAmt), shift(ShiftedC2, add(ShAmt, AddC))) -> shift(binop(ShiftedC1, shift(ShiftedC2, AddC)), ShAmt)
where both shifts are the same and AddC is a valid shift amount.
Paths
| Differential D152927
[InstCombine] Fold binop of shifts with related amounts ClosedPublic Authored by nikic on Jun 14 2023, 8:32 AM.
Details Summary Fold binop(shift(ShiftedC1, ShAmt), shift(ShiftedC2, add(ShAmt, AddC))) -> shift(binop(ShiftedC1, shift(ShiftedC2, AddC)), ShAmt) where both shifts are the same and AddC is a valid shift amount.
Diff Detail
Event Timeline
nikic retitled this revision from [InstCombine] Fold binop op shifts with related amounts to [InstCombine] Fold binop of shifts with related amounts.Jun 15 2023, 1:54 AM
This revision is now accepted and ready to land.Jun 27 2023, 10:10 AM Closed by commit rGb45a73f4d074: [InstCombine] Fold binop of shifts with related amounts (authored by nikic). · Explain WhyJun 28 2023, 1:00 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 535272 llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/test/Transforms/InstCombine/binop-of-displaced-shifts.ll
|
https://alive2.llvm.org/ce/z/Y46Cnq add with shl works as well. Fine with only handling BW for now but maybe InstructionCombining.cpp is a better place to put this so its easier to extend in the future.