[PATCH] D93841: [GVN] Use m_LogicalAnd/Or to propagate equality from branch conditions

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 27 12:28:59 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1d648b973d3: [GVN] Use m_LogicalAnd/Or to propagate equality from branch conditions (authored by aqjune).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93841

Files:
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/test/Transforms/GVN/condprop.ll


Index: llvm/test/Transforms/GVN/condprop.ll
===================================================================
--- llvm/test/Transforms/GVN/condprop.ll
+++ llvm/test/Transforms/GVN/condprop.ll
@@ -87,13 +87,13 @@
   br i1 %z, label %both_zero, label %nope
 both_zero:
   call void @foo(i1 %xz)
-; CHECK: call void @foo(i1 %xz)
+; CHECK: call void @foo(i1 true)
   call void @foo(i1 %yz)
-; CHECK: call void @foo(i1 %yz)
+; CHECK: call void @foo(i1 true)
   call void @bar(i32 %x)
-; CHECK: call void @bar(i32 %x)
+; CHECK: call void @bar(i32 0)
   call void @bar(i32 %y)
-; CHECK: call void @bar(i32 %y)
+; CHECK: call void @bar(i32 0)
   ret void
 nope:
   call void @foo(i1 %z)
@@ -131,13 +131,13 @@
   br i1 %z, label %nope, label %both_zero
 both_zero:
   call void @foo(i1 %xz)
-; CHECK: call void @foo(i1 %xz)
+; CHECK: call void @foo(i1 false)
   call void @foo(i1 %yz)
-; CHECK: call void @foo(i1 %yz)
+; CHECK: call void @foo(i1 false)
   call void @bar(i32 %x)
-; CHECK: call void @bar(i32 %x)
+; CHECK: call void @bar(i32 0)
   call void @bar(i32 %y)
-; CHECK: call void @bar(i32 %y)
+; CHECK: call void @bar(i32 0)
   ret void
 nope:
   call void @foo(i1 %z)
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2087,8 +2087,8 @@
     // If "A && B" is known true then both A and B are known true.  If "A || B"
     // is known false then both A and B are known false.
     Value *A, *B;
-    if ((isKnownTrue && match(LHS, m_And(m_Value(A), m_Value(B)))) ||
-        (isKnownFalse && match(LHS, m_Or(m_Value(A), m_Value(B))))) {
+    if ((isKnownTrue && match(LHS, m_LogicalAnd(m_Value(A), m_Value(B)))) ||
+        (isKnownFalse && match(LHS, m_LogicalOr(m_Value(A), m_Value(B))))) {
       Worklist.push_back(std::make_pair(A, RHS));
       Worklist.push_back(std::make_pair(B, RHS));
       continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93841.313800.patch
Type: text/x-patch
Size: 1957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201227/cc264cee/attachment.bin>


More information about the llvm-commits mailing list