'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.
Differential D63670
[InstCombine][NFC] Add test to show missing fold for icmp ult/uge (shl %x, C2), C1. huihuiz on Jun 21 2019, 2:00 PM. Authored by
Details '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
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 |
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.