[InstCombine] C0 shift (X add nuw C) --> (C0 shift C) shift X
authorSanjay Patel <spatel@rotateright.com>
Tue, 19 Apr 2022 19:09:45 +0000 (15:09 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 19 Apr 2022 19:21:34 +0000 (15:21 -0400)
commit8a9c70fc01e6c900f060f3c23d96ee444be33a9a
tree05eeccdc3d03fe7f6e7032c64b763ae3cc243f4b
parenta9aa14e0cbb26ada60e28099ba6cafca4e990ba0
[InstCombine] C0 shift (X add nuw C) --> (C0 shift C) shift X

With 'nuw' we can convert the increment of the shift amount
into a pre-shift (constant fold) of the shifted constant:
https://alive2.llvm.org/ce/z/FkTyR2

Fixes issue #41976
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/shift-add.ll