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

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 21 17:31:46 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGace0bf749099: [ValueTracking] Fix incorrect handling of canCreateUndefOrPoison (authored by aqjune).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84251/new/

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.279677.patch
Type: text/x-patch
Size: 1209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200722/6c9b612a/attachment.bin>


More information about the llvm-commits mailing list