[PATCH] D128217: [ValueTracking] Teach isKnownNonZero that a vscale is never 0.
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 23 07:25:42 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd1a4c8565ac: [ValueTracking] Teach isKnownNonZero that a vscale is never 0. (authored by dmgreen).
Changed prior to commit:
https://reviews.llvm.org/D128217?vs=438439&id=439391#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128217/new/
https://reviews.llvm.org/D128217
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/vscale_zero.ll
Index: llvm/test/Transforms/InstCombine/vscale_zero.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/InstCombine/vscale_zero.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+define i1 @iszero() {
+; CHECK-LABEL: @iszero(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: ret i1 false
+;
+ entry:
+ %0 = call i32 @llvm.vscale.i32()
+ %1 = icmp eq i32 %0, 0
+ ret i1 %1
+}
+
+define i1 @iszero_range() vscale_range(1,16) {
+; CHECK-LABEL: @iszero_range(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: ret i1 false
+;
+ entry:
+ %0 = call i32 @llvm.vscale.i32()
+ %1 = icmp eq i32 %0, 0
+ ret i1 %1
+}
+
+declare i32 @llvm.vscale.i32()
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -2698,6 +2698,9 @@
if (isKnownNonZero(Op, Depth, Q) &&
isGuaranteedNotToBePoison(Op, Q.AC, Q.CxtI, Q.DT, Depth))
return true;
+ } else if (const auto *II = dyn_cast<IntrinsicInst>(V)) {
+ if (II->getIntrinsicID() == Intrinsic::vscale)
+ return true;
}
KnownBits Known(BitWidth);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128217.439391.patch
Type: text/x-patch
Size: 1302 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220623/274c32f2/attachment.bin>
More information about the llvm-commits
mailing list