[PATCH] D84251: [ValueTracking] Fix incorrect handling of canCreateUndefOrPoison

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 21 10:40:09 PDT 2020


aqjune created this revision.
aqjune added a reviewer: nikic.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

.. in isGuaranteedNotToBeUndefOrPoison.

This caused early exit of isGuaranteedNotToBeUndefOrPoison, making it return
imprecise result.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84251

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/InstSimplify/freeze.ll


Index: llvm/test/Transforms/InstSimplify/freeze.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/freeze.ll
+++ llvm/test/Transforms/InstSimplify/freeze.ll
@@ -381,6 +381,23 @@
   ret i32 %fr2
 }
 
+declare i32 @any_num()
+
+define i32 @brcond_call() {
+; CHECK-LABEL: @brcond_call(
+; CHECK-NEXT:    [[X:%.*]] = call i32 @any_num()
+; CHECK-NEXT:    switch i32 [[X]], label [[EXIT:%.*]] [
+; CHECK-NEXT:    ]
+; CHECK:       EXIT:
+; CHECK-NEXT:    ret i32 [[X]]
+;
+  %x = call i32 @any_num()
+  switch i32 %x, label %EXIT []
+EXIT:
+  %y = freeze i32 %x
+  ret i32 %y
+}
+
 define i1 @brcond_noopt(i1 %c, i1 %c2) {
 ; CHECK-LABEL: @brcond_noopt(
 ; CHECK-NEXT:    [[F:%.*]] = freeze i1 [[C:%.*]]
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -4824,10 +4824,7 @@
         return true;
     }
 
-    if (canCreateUndefOrPoison(Opr))
-      return false;
-
-    if (all_of(Opr->operands(), OpCheck))
+    if (!canCreateUndefOrPoison(Opr) && all_of(Opr->operands(), OpCheck))
       return true;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84251.279574.patch
Type: text/x-patch
Size: 1209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200721/a8f6ff5b/attachment.bin>


More information about the llvm-commits mailing list