[PATCH] D11345: ignore duplicate divisor uses when transforming into reciprocal multiplies (PR24141)

Sanjay Patel spatel at rotateright.com
Tue Jul 28 16:28:53 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL243500: ignore duplicate divisor uses when transforming into reciprocal multiplies… (authored by spatel).

Changed prior to commit:
  http://reviews.llvm.org/D11345?vs=30192&id=30873#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11345

Files:
  llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/trunk/test/CodeGen/X86/fdiv-combine.ll

Index: llvm/trunk/test/CodeGen/X86/fdiv-combine.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/fdiv-combine.ll
+++ llvm/trunk/test/CodeGen/X86/fdiv-combine.ll
@@ -44,5 +44,24 @@
   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" }
Index: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -8261,11 +8261,11 @@
     return SDValue();
 
   // Find all FDIV users of the same divisor.
-  SmallVector<SDNode *, 4> Users;
-  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);
 
   // Now that we have the actual number of divisor uses, make sure it meets
   // the minimum threshold specified by the target.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11345.30873.patch
Type: text/x-patch
Size: 1641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150728/6d9c00a5/attachment.bin>


More information about the llvm-commits mailing list