[PATCH] D47878: [DAGCombiner] Fix for PR37667

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 8 00:53:34 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL334268: [DAGCombine] Fix for PR37667 (authored by sam_parker, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47878?vs=150342&id=150455#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47878

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


Index: llvm/trunk/test/CodeGen/X86/backpropmask.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/backpropmask.ll
+++ llvm/trunk/test/CodeGen/X86/backpropmask.ll
@@ -1,25 +1,20 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
 
-; FIXME:
-; Verify that backwards propagation of a mask does not affect
-; nodes with multiple result values. In both tests, the stored
-; 32-bit value should be masked to an 8-bit number (and 255).
-
 @b = local_unnamed_addr global i32 918, align 4
 @d = local_unnamed_addr global i32 8089, align 4
 @c = common local_unnamed_addr global i32 0, align 4
 @a = common local_unnamed_addr global i32 0, align 4
 
 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 +32,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: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/trunk/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, e = NodeToMask->getNumValues(); i < e; ++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.150455.patch
Type: text/x-patch
Size: 2674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180608/fc16cc66/attachment.bin>


More information about the llvm-commits mailing list