[InstCombine] (X << Y) / X -> 1 << Y
authorSanjay Patel <spatel@rotateright.com>
Sun, 21 Jan 2018 16:14:51 +0000 (16:14 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sun, 21 Jan 2018 16:14:51 +0000 (16:14 +0000)
commit9530f1886433d77bc203c366915a9ab3160c7efc
tree7713b04c77141e282a864a0e30e243e64ab4a143
parent7a44e4d594c98b5998ebffc041490564953a3cb8
[InstCombine] (X << Y) / X -> 1 << Y

...when the shift is known to not overflow with the matching
signed-ness of the division.

This closes an optimization gap caused by canonicalizing mul
by power-of-2 to shl as shown in PR35709:
https://bugs.llvm.org/show_bug.cgi?id=35709

Patch by Anton Bikineev!

Differential Revision: https://reviews.llvm.org/D42032

llvm-svn: 323068
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/div-shift.ll