aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorNoah Goldstein <goldstein.w.n@gmail.com>2023-04-14 14:34:23 -0500
committerNoah Goldstein <goldstein.w.n@gmail.com>2023-04-14 18:23:47 -0500
commitf688d215e53cdeaaa90b317bb476acd6cebabf2c (patch)
treefbfbeaf698c909f124f3732bc0bcc0a6fc727b14 /llvm/lib/Analysis/ValueTracking.cpp
parent684963b86db3d4d1eebd3985b8161af90187e938 (diff)
downloadllvm-f688d215e53cdeaaa90b317bb476acd6cebabf2c.zip
llvm-f688d215e53cdeaaa90b317bb476acd6cebabf2c.tar.gz
llvm-f688d215e53cdeaaa90b317bb476acd6cebabf2c.tar.bz2
[ValueTracking] Add `shl nsw %val, %cnt != 0` if `%val != 0`.
Alive2 Link: https://alive2.llvm.org/ce/z/mxZLJn Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D147898
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 3a9e80c..eae6261 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2670,9 +2670,9 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
return isKnownNonZero(I->getOperand(0), Depth, Q);
case Instruction::Shl: {
- // shl nuw can't remove any non-zero bits.
+ // shl nsw/nuw can't remove any non-zero bits.
const OverflowingBinaryOperator *BO = cast<OverflowingBinaryOperator>(V);
- if (Q.IIQ.hasNoUnsignedWrap(BO))
+ if (Q.IIQ.hasNoUnsignedWrap(BO) || Q.IIQ.hasNoSignedWrap(BO))
return isKnownNonZero(I->getOperand(0), Depth, Q);
// shl X, Y != 0 if X is odd. Note that the value of the shift is undefined