[llvm-branch-commits] [llvm-branch] r243524 - Merging r243500: (conflicts resolved manually since the branch doesn't have r243293)

Hans Wennborg hans at hanshq.net
Wed Jul 29 08:38:38 PDT 2015


Author: hans
Date: Wed Jul 29 10:38:37 2015
New Revision: 243524

URL: http://llvm.org/viewvc/llvm-project?rev=243524&view=rev
Log:
Merging r243500: (conflicts resolved manually since the branch doesn't have r243293)
------------------------------------------------------------------------
r243500 | spatel | 2015-07-28 16:28:22 -0700 (Tue, 28 Jul 2015) | 16 lines

ignore duplicate divisor uses when transforming into reciprocal multiplies (PR24141)

PR24141: https://llvm.org/bugs/show_bug.cgi?id=24141
contains a test case where we have duplicate entries in a node's uses() list.

After r241826, we use CombineTo() to delete dead nodes when combining the uses into
reciprocal multiplies, but this fails if we encounter the just-deleted node again in
the list.

The solution in this patch is to not add duplicate entries to the list of users that
we will subsequently iterate over. For the test case, this avoids triggering the
combine divisors logic entirely because there really is only one user of the divisor.

Differential Revision: http://reviews.llvm.org/D11345
------------------------------------------------------------------------

Modified:
    llvm/branches/release_37/   (props changed)
    llvm/branches/release_37/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    llvm/branches/release_37/test/CodeGen/X86/fdiv-combine.ll

Propchange: llvm/branches/release_37/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 29 10:38:37 2015
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,242236,242239,242281,242288,242296,242331,242341,242410,242412,242433-242434,242442,242543,242673,242680,242706,242721-242722,242733-242735,242742,242869,242919,242993,243001,243116,243263,243294,243361
+/llvm/trunk:155241,242236,242239,242281,242288,242296,242331,242341,242410,242412,242433-242434,242442,242543,242673,242680,242706,242721-242722,242733-242735,242742,242869,242919,242993,243001,243116,243263,243294,243361,243500

Modified: llvm/branches/release_37/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_37/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=243524&r1=243523&r2=243524&view=diff
==============================================================================
--- llvm/branches/release_37/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/branches/release_37/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Jul 29 10:38:37 2015
@@ -8365,12 +8365,12 @@ SDValue DAGCombiner::visitFDIV(SDNode *N
     if (N0CFP && N0CFP->isExactlyValue(1.0))
       return SDValue();
 
-    SmallVector<SDNode *, 4> Users;
     // Find all FDIV users of the same divisor.
-    for (auto *U : N1->uses()) {
+    // Use a set because duplicates may be present in the user list.
+    SetVector<SDNode *> Users;
+    for (auto *U : N1->uses())
       if (U->getOpcode() == ISD::FDIV && U->getOperand(1) == N1)
-        Users.push_back(U);
-    }
+        Users.insert(U);
 
     if (TLI.combineRepeatedFPDivisors(Users.size())) {
       SDValue FPOne = DAG.getConstantFP(1.0, DL, VT);

Modified: llvm/branches/release_37/test/CodeGen/X86/fdiv-combine.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_37/test/CodeGen/X86/fdiv-combine.ll?rev=243524&r1=243523&r2=243524&view=diff
==============================================================================
--- llvm/branches/release_37/test/CodeGen/X86/fdiv-combine.ll (original)
+++ llvm/branches/release_37/test/CodeGen/X86/fdiv-combine.ll Wed Jul 29 10:38:37 2015
@@ -44,5 +44,24 @@ define double @div3_arcp(double %x, doub
   ret double %ret
 }
 
+define void @PR24141() #0 {
+; CHECK-LABEL: PR24141:
+; CHECK:	callq
+; CHECK-NEXT:	divsd
+; CHECK-NEXT:	jmp
+entry:
+  br label %while.body
+
+while.body:
+  %x.0 = phi double [ undef, %entry ], [ %div, %while.body ]
+  %call = call { double, double } @g(double %x.0)
+  %xv0 = extractvalue { double, double } %call, 0
+  %xv1 = extractvalue { double, double } %call, 1
+  %div = fdiv double %xv0, %xv1
+  br label %while.body
+}
+
+declare { double, double } @g(double)
+
 ; FIXME: If the backend understands 'arcp', then this attribute is unnecessary.
 attributes #0 = { "unsafe-fp-math"="true" }





More information about the llvm-branch-commits mailing list