[PATCH] D28406: [InstCombine] icmp sgt (shl nsw X, C1), C0 --> icmp sgt X, C0 >> C1
bryant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 18 22:00:27 PST 2017
bryant added a comment.
LGTM with just one nit.
================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:1915
- // If this is a signed comparison to 0 and the shift is sign preserving,
- // use the shift LHS operand instead; isSignTest may change 'Pred', so only
- // do that if we're sure to not continue on in this function.
- if (Shl->hasNoSignedWrap() && isSignTest(Pred, *C))
- return new ICmpInst(Pred, X, Constant::getNullValue(ShType));
+ // A 'shl nsw' is just shifting out sign bits, so adjust the compare constant
+ // and eliminate the shift.
----------------
`shl nsw` is also shifting out zeroes, no? It's `ashr` that shifts in sign bits.
https://reviews.llvm.org/D28406
More information about the llvm-commits
mailing list