[PATCH] D79748: [ValueTracking] And & Or propagate poison.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 11 15:07:46 PDT 2020
fhahn created this revision.
fhahn added reviewers: aqjune, nlopes, reames.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Both And and Or instructions propagate poison if any operand is poison.
Note the TODO in the function that most instructions expect a few should
propagate poison, but it is probably safer to enable them step-by-step.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79748
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ScalarEvolution/nsw.ll
Index: llvm/test/Analysis/ScalarEvolution/nsw.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/nsw.ll
+++ llvm/test/Analysis/ScalarEvolution/nsw.ll
@@ -223,8 +223,26 @@
ret void
}
-define void @bad_postinc_nsw_b(i32 %n) {
-; CHECK-LABEL: Classifying expressions for: @bad_postinc_nsw_b
+define void @bad_postinc_nsw_b_or(i32 %n) {
+; CHECK-LABEL: Classifying expressions for: @bad_postinc_nsw_b_or
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
+ %iv.inc = add nsw i32 %iv, 7
+ %iv.inc.and = or i32 %iv.inc, 0
+; CHECK: %iv.inc = add nsw i32 %iv, 7
+; CHECK-NEXT: --> {7,+,7}<nuw><nsw><%loop>
+ %becond = icmp ult i32 %iv.inc.and, %n
+ br i1 %becond, label %loop, label %leave
+
+leave:
+ ret void
+}
+
+define void @bad_postinc_nsw_b_and(i32 %n) {
+; CHECK-LABEL: Classifying expressions for: @bad_postinc_nsw_b_and
entry:
br label %loop
@@ -233,7 +251,7 @@
%iv.inc = add nsw i32 %iv, 7
%iv.inc.and = and i32 %iv.inc, 0
; CHECK: %iv.inc = add nsw i32 %iv, 7
-; CHECK-NEXT: --> {7,+,7}<nuw><%loop>
+; CHECK-NEXT: --> {7,+,7}<nuw><nsw><%loop>
%becond = icmp ult i32 %iv.inc.and, %n
br i1 %becond, label %loop, label %leave
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -4950,6 +4950,8 @@
case Instruction::Mul:
case Instruction::Shl:
case Instruction::GetElementPtr:
+ case Instruction::And:
+ case Instruction::Or:
// These operations all propagate poison unconditionally. Note that poison
// is not any particular value, so xor or subtraction of poison with
// itself still yields poison, not zero.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79748.263286.patch
Type: text/x-patch
Size: 1818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200511/23ab9d32/attachment.bin>
More information about the llvm-commits
mailing list