'shl' inequality test
icmp ult/uge (shl %x, C2), C1 iff C1 is power of two
can be simplified as 'and' equality test
icmp eq/ne (and %x, (lshr -C1, C2)), 0.
Paths
| Differential D63670
[InstCombine][NFC] Add test to show missing fold for icmp ult/uge (shl %x, C2), C1. ClosedPublic Authored by huihuiz on Jun 21 2019, 2:00 PM.
Details Summary 'shl' inequality test icmp ult/uge (shl %x, C2), C1 iff C1 is power of two can be simplified as 'and' equality test icmp eq/ne (and %x, (lshr -C1, C2)), 0.
Diff Detail
Event Timeline
This revision is now accepted and ready to land.Jun 24 2019, 3:13 PM Comment Actions Added vector test to check for predicate variance. Comment Actions
Right, i forgot to enable instcombine in my godbolt link :) Comment Actions minor update for vector test, for vector test (X l<< 11) u<= 131071 , not 131072 } similar for ugt test sorry didn't catch this earlier Closed by commit rL364256: [InstCombine][NFC] Add test to show missing fold for icmp ult/uge (shl %x, C2)… (authored by huihuiz). · Explain WhyJun 24 2019, 5:16 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 206314 llvm/test/Transforms/InstCombine/shl-unsigned-cmp-const.ll
|
Yeah, it's not really possible to ensure that those folds happen, the predicate is canonicalized.
I'd recommend to add those tests with predicate variants using vectors: https://godbolt.org/z/69dzCf
^ Looks like those aren't being canonicalized, at least right now.