[PATCH] D47878: [DAGCombiner] Fix for PR37667

Sam Parker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 7 08:35:10 PDT 2018


samparker updated this revision to Diff 150342.
samparker added a comment.

Thanks for the feedback. I've removed my new test and updated the existed one. Also modified the code style.


https://reviews.llvm.org/D47878

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  test/CodeGen/X86/backpropmask.ll


Index: test/CodeGen/X86/backpropmask.ll
===================================================================
--- test/CodeGen/X86/backpropmask.ll
+++ test/CodeGen/X86/backpropmask.ll
@@ -14,12 +14,12 @@
 define void @PR37667() {
 ; CHECK-LABEL: PR37667:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    movzbl {{.*}}(%rip), %ecx
 ; CHECK-NEXT:    movl {{.*}}(%rip), %eax
 ; CHECK-NEXT:    xorl %edx, %edx
 ; CHECK-NEXT:    divl {{.*}}(%rip)
-; CHECK-NEXT:    orl %ecx, %edx
-; CHECK-NEXT:    movl %edx, {{.*}}(%rip)
+; CHECK-NEXT:    orl {{.*}}(%rip), %edx
+; CHECK-NEXT:    movzbl %dl, %eax
+; CHECK-NEXT:    movl %eax, {{.*}}(%rip)
 ; CHECK-NEXT:    retq
   %t0 = load i32, i32* @c, align 4
   %t1 = load i32, i32* @b, align 4
@@ -37,8 +37,8 @@
 ; CHECK-NEXT:    movl $-1, %eax
 ; CHECK-NEXT:    cltd
 ; CHECK-NEXT:    idivl {{.*}}(%rip)
-; CHECK-NEXT:    movzbl {{.*}}(%rip), %eax
-; CHECK-NEXT:    xorl %edx, %eax
+; CHECK-NEXT:    xorl {{.*}}(%rip), %edx
+; CHECK-NEXT:    movzbl %dl, %eax
 ; CHECK-NEXT:    movl %eax, {{.*}}(%rip)
 ; CHECK-NEXT:    retq
   %t0 = load i32, i32* @c, align 4
Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3997,7 +3997,23 @@
     // Allow one node which will masked along with any loads found.
     if (NodeToMask)
       return false;
+ 
+    // Also ensure that the node to be masked only produces one data result. 
     NodeToMask = Op.getNode();
+    if (NodeToMask->getNumValues() > 1) {
+      bool HasValue = false;
+      for (unsigned i = 0; i < NodeToMask->getNumValues(); ++i) {
+        MVT VT = SDValue(NodeToMask, i).getSimpleValueType();
+        if (VT != MVT::Glue && VT != MVT::Other) {
+          if (HasValue) {
+            NodeToMask = nullptr;
+            return false;
+          }
+          HasValue = true;
+        }
+      }
+      assert(HasValue && "Node to be masked has no data result?");
+    }
   }
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47878.150342.patch
Type: text/x-patch
Size: 2047 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180607/0ea515f9/attachment.bin>


More information about the llvm-commits mailing list