llvm.org GIT mirror llvm / 1008467
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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@243524 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 5 years ago
2 changed file(s) with 23 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
83648364 if (N0CFP && N0CFP->isExactlyValue(1.0))
83658365 return SDValue();
83668366
8367 SmallVector Users;
83688367 // Find all FDIV users of the same divisor.
8369 for (auto *U : N1->uses()) {
8368 // Use a set because duplicates may be present in the user list.
8369 SetVector Users;
8370 for (auto *U : N1->uses())
83708371 if (U->getOpcode() == ISD::FDIV && U->getOperand(1) == N1)
8371 Users.push_back(U);
8372 }
8372 Users.insert(U);
83738373
83748374 if (TLI.combineRepeatedFPDivisors(Users.size())) {
83758375 SDValue FPOne = DAG.getConstantFP(1.0, DL, VT);
4343 ret double %ret
4444 }
4545
46 define void @PR24141() #0 {
47 ; CHECK-LABEL: PR24141:
48 ; CHECK: callq
49 ; CHECK-NEXT: divsd
50 ; CHECK-NEXT: jmp
51 entry:
52 br label %while.body
53
54 while.body:
55 %x.0 = phi double [ undef, %entry ], [ %div, %while.body ]
56 %call = call { double, double } @g(double %x.0)
57 %xv0 = extractvalue { double, double } %call, 0
58 %xv1 = extractvalue { double, double } %call, 1
59 %div = fdiv double %xv0, %xv1
60 br label %while.body
61 }
62
63 declare { double, double } @g(double)
64
4665 ; FIXME: If the backend understands 'arcp', then this attribute is unnecessary.
4766 attributes #0 = { "unsafe-fp-math"="true" }