This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Dropping redundant masking before right-shift (PR42456)
Changes PlannedPublic

Authored by lebedev.ri on Jul 2 2019, 3:31 AM.

Details

Summary

If we have:
(X & (-1 << Y)) outer>> Y
Or non-canonical
((X inner>> Y) << Y) outer>> Y
The mask is redundant, and can be dropped:
X outer>> Y
This is valid for both lshr and ashr` in both positions and any combination.
https://rise4fun.com/Alive/Vf1p

We must not preserve exact:
https://rise4fun.com/Alive/DYq
https://rise4fun.com/Alive/JXjy

Should fix PR42456

Diff Detail

Repository
rL LLVM

Event Timeline

lebedev.ri created this revision.Jul 2 2019, 3:31 AM
lebedev.ri planned changes to this revision.Jul 3 2019, 7:41 AM

Will get back to this.