This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] foldICmpWithLowBitMaskedVal(): handle uncanonical ((1 << y)+(-1)) mask
ClosedPublic

Authored by lebedev.ri on Sep 16 2018, 1:37 AM.

Details

Summary

Same as to D52146.
((1 << y)+(-1)) is simply non-canoniacal version of ~(-1 << y): https://rise4fun.com/Alive/0vl
We can not canonicalize it due to the extra uses. But we can handle it here.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel accepted this revision.Sep 18 2018, 10:18 AM

As discussed in D52146, this is a close call. We don't have evidence to suggest that the non-canonical pattern occurs often in real code, but it was spotted somewhere in the wild, and it's nice that we can fold this pattern regardless of extra uses. OTOH, instcombine keeps growing bigger and slower. But given past policy in these situations, we don't block tiny patches like this just because the fold is unlikely, so LGTM.

This revision is now accepted and ready to land.Sep 18 2018, 10:18 AM
This revision was automatically updated to reflect the committed changes.