HomePhabricator

[InstCombine] (X << Y) / X -> 1 << Y

Description

[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

Details

Committed
spatelJan 21 2018, 8:14 AM
Differential Revision
D42032: [LLVM][PASSES][InstCombine] Fix (a + a + ...) / a cases
Parents
rL323067: [InstSimplify] add baseline tests for (X << Y) % X -> 0; NFC
Branches
Unknown
Tags
Unknown