[PATCH] D147898: [ValueTracking] Add `shl nsw %val, %cnt != 0` if `%val != 0`.
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 10:25:34 PDT 2023
goldstein.w.n updated this revision to Diff 513666.
goldstein.w.n added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147898/new/
https://reviews.llvm.org/D147898
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ValueTracking/known-non-zero.ll
Index: llvm/test/Analysis/ValueTracking/known-non-zero.ll
===================================================================
--- llvm/test/Analysis/ValueTracking/known-non-zero.ll
+++ llvm/test/Analysis/ValueTracking/known-non-zero.ll
@@ -227,9 +227,7 @@
; CHECK-LABEL: @shl_non_zero_nsw(
; CHECK-NEXT: [[NZ:%.*]] = icmp ne i8 [[S:%.*]], 0
; CHECK-NEXT: call void @llvm.assume(i1 [[NZ]])
-; CHECK-NEXT: [[V:%.*]] = shl nsw i8 [[S]], [[CNT:%.*]]
-; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 false
;
%nz = icmp ne i8 %s, 0
call void @llvm.assume(i1 %nz)
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -2670,9 +2670,9 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147898.513666.patch
Type: text/x-patch
Size: 1358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230414/fbb90df1/attachment.bin>
More information about the llvm-commits
mailing list