[InstCombine] fold shift-right-by-constant with shift-right-of-constant operand
authorSanjay Patel <spatel@rotateright.com>
Mon, 30 May 2022 19:30:01 +0000 (15:30 -0400)
committerSanjay Patel <spatel@rotateright.com>
Mon, 30 May 2022 19:30:01 +0000 (15:30 -0400)
commita0c3c60728ee5bc7d6ca40a5b6e446cde72c6700
tree62dc88377f1ad31dcf75e80b00c9b0933ac0a62c
parentc5d942a4fb21fba404ceb504ed087c297a1af7c3
[InstCombine] fold shift-right-by-constant with shift-right-of-constant operand

  (C2 >> X) >> C1 --> (C2 >> C1) >> X

The shift-left form of this transform has existed since:
16f18ed7b555bce5163

...but it applies to matching shift right opcodes too:
https://alive2.llvm.org/ce/z/c5eQms
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/and.ll
llvm/test/Transforms/InstCombine/icmp-and-shift.ll
llvm/test/Transforms/InstCombine/shift-shift.ll