Skip to content

Commit d6be62c

Browse files
committed
[InstCombine] Fix the correctness of missing check reassoc flag
The potential issue is based on the discussion of PR69998. The Transfrom is reasonable when the I and all of its operands have the reassoc flag. Also add some reassoc to the original test case to retain the original optimization logic. NOTE: The IR node may have different fast math flags within a function if you're doing LTO.
1 parent a0710e1 commit d6be62c

File tree

11 files changed

+146
-122
lines changed

11 files changed

+146
-122
lines changed

llvm/include/llvm/IR/Instruction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ class Instruction : public User,
452452
/// instruction.
453453
void setNonNeg(bool b = true);
454454

455+
/// Checks all of its operands have reassoc flag if they are instruction.
456+
bool hasAllowReassocOfAllOperand() const LLVM_READONLY;
457+
455458
/// Determine whether the no unsigned wrap flag is set.
456459
bool hasNoUnsignedWrap() const LLVM_READONLY;
457460

llvm/lib/IR/Instruction.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,27 @@ void Instruction::setNonNeg(bool b) {
321321
(b * PossiblyNonNegInst::NonNeg);
322322
}
323323

324+
bool Instruction::hasAllowReassocOfAllOperand() const {
325+
return all_of(operands(), [](Value *V) {
326+
if (!isa<FPMathOperator>(V))
327+
return true;
328+
329+
auto *FPOp = cast<FPMathOperator>(V);
330+
switch (FPOp->getOpcode()) {
331+
case Instruction::FNeg:
332+
case Instruction::FAdd:
333+
case Instruction::FSub:
334+
case Instruction::FMul:
335+
case Instruction::FDiv:
336+
case Instruction::FRem:
337+
return FPOp->hasAllowReassoc();
338+
339+
default:
340+
return true;
341+
}
342+
});
343+
}
344+
324345
bool Instruction::hasNoUnsignedWrap() const {
325346
return cast<OverflowingBinaryOperator>(this)->hasNoUnsignedWrap();
326347
}

llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ Instruction *InstCombinerImpl::visitFMul(BinaryOperator &I) {
781781
if (Value *V = SimplifySelectsFeedingBinaryOp(I, Op0, Op1))
782782
return replaceInstUsesWith(I, V);
783783

784-
if (I.hasAllowReassoc())
784+
if (I.hasAllowReassoc() && I.hasAllowReassocOfAllOperand())
785785
if (Instruction *FoldedMul = foldFMulReassoc(I))
786786
return FoldedMul;
787787

llvm/test/Transforms/InstCombine/extractelement.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ define float @crash_4b8320(<2 x float> %i1, float %i12) {
912912
; ANY-NEXT: [[I29:%.*]] = fadd float [[TMP3]], 0.000000e+00
913913
; ANY-NEXT: ret float [[I29]]
914914
;
915-
%i5 = fmul <2 x float> zeroinitializer, %i1
915+
%i5 = fmul reassoc <2 x float> zeroinitializer, %i1
916916
%i6 = fmul reassoc <2 x float> zeroinitializer, %i5
917917
%i147 = extractelement <2 x float> %i6, i64 0
918918
%i15 = extractelement <2 x float> %i6, i64 0

llvm/test/Transforms/InstCombine/fast-math.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ define float @fdiv1(float %x) {
562562
; CHECK-NEXT: [[DIV1:%.*]] = fmul fast float [[X:%.*]], 0x3FD7303B60000000
563563
; CHECK-NEXT: ret float [[DIV1]]
564564
;
565-
%div = fdiv float %x, 0x3FF3333340000000
565+
%div = fdiv reassoc float %x, 0x3FF3333340000000
566566
%div1 = fdiv fast float %div, 0x4002666660000000
567567
ret float %div1
568568
; 0x3FF3333340000000 = 1.2f
@@ -603,7 +603,7 @@ define float @fdiv3(float %x) {
603603
; CHECK-NEXT: [[DIV1:%.*]] = fdiv fast float [[TMP1]], 0x47EFFFFFE0000000
604604
; CHECK-NEXT: ret float [[DIV1]]
605605
;
606-
%div = fdiv float %x, 0x47EFFFFFE0000000
606+
%div = fdiv reassoc float %x, 0x47EFFFFFE0000000
607607
%div1 = fdiv fast float %div, 0x4002666660000000
608608
ret float %div1
609609
}

llvm/test/Transforms/InstCombine/fmul-exp.ll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ define double @exp_a_exp_b(double %a, double %b) {
2121
; exp(a) * exp(b) reassoc, multiple uses
2222
define double @exp_a_exp_b_multiple_uses(double %a, double %b) {
2323
; CHECK-LABEL: @exp_a_exp_b_multiple_uses(
24-
; CHECK-NEXT: [[T1:%.*]] = call double @llvm.exp.f64(double [[B:%.*]])
24+
; CHECK-NEXT: [[T1:%.*]] = call reassoc double @llvm.exp.f64(double [[B:%.*]])
2525
; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc double [[A:%.*]], [[B]]
2626
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.exp.f64(double [[TMP1]])
2727
; CHECK-NEXT: call void @use(double [[T1]])
2828
; CHECK-NEXT: ret double [[MUL]]
2929
;
30-
%t = call double @llvm.exp.f64(double %a)
31-
%t1 = call double @llvm.exp.f64(double %b)
30+
%t = call reassoc double @llvm.exp.f64(double %a)
31+
%t1 = call reassoc double @llvm.exp.f64(double %b)
3232
%mul = fmul reassoc double %t, %t1
3333
call void @use(double %t1)
3434
ret double %mul
@@ -59,8 +59,8 @@ define double @exp_a_exp_b_reassoc(double %a, double %b) {
5959
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.exp.f64(double [[TMP1]])
6060
; CHECK-NEXT: ret double [[MUL]]
6161
;
62-
%t = call double @llvm.exp.f64(double %a)
63-
%t1 = call double @llvm.exp.f64(double %b)
62+
%t = call reassoc double @llvm.exp.f64(double %a)
63+
%t1 = call reassoc double @llvm.exp.f64(double %b)
6464
%mul = fmul reassoc double %t, %t1
6565
ret double %mul
6666
}
@@ -71,7 +71,7 @@ define double @exp_a_a(double %a) {
7171
; CHECK-NEXT: [[M:%.*]] = call reassoc double @llvm.exp.f64(double [[TMP1]])
7272
; CHECK-NEXT: ret double [[M]]
7373
;
74-
%t = call double @llvm.exp.f64(double %a)
74+
%t = call reassoc double @llvm.exp.f64(double %a)
7575
%m = fmul reassoc double %t, %t
7676
ret double %m
7777
}
@@ -100,12 +100,12 @@ define double @exp_a_exp_b_exp_c_exp_d_fast(double %a, double %b, double %c, dou
100100
; CHECK-NEXT: [[MUL2:%.*]] = call reassoc double @llvm.exp.f64(double [[TMP3]])
101101
; CHECK-NEXT: ret double [[MUL2]]
102102
;
103-
%t = call double @llvm.exp.f64(double %a)
104-
%t1 = call double @llvm.exp.f64(double %b)
103+
%t = call reassoc double @llvm.exp.f64(double %a)
104+
%t1 = call reassoc double @llvm.exp.f64(double %b)
105105
%mul = fmul reassoc double %t, %t1
106-
%t2 = call double @llvm.exp.f64(double %c)
106+
%t2 = call reassoc double @llvm.exp.f64(double %c)
107107
%mul1 = fmul reassoc double %mul, %t2
108-
%t3 = call double @llvm.exp.f64(double %d)
108+
%t3 = call reassoc double @llvm.exp.f64(double %d)
109109
%mul2 = fmul reassoc double %mul1, %t3
110110
ret double %mul2
111111
}

llvm/test/Transforms/InstCombine/fmul-exp2.ll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ define double @exp2_a_exp2_b(double %a, double %b) {
2121
; exp2(a) * exp2(b) reassoc, multiple uses
2222
define double @exp2_a_exp2_b_multiple_uses(double %a, double %b) {
2323
; CHECK-LABEL: @exp2_a_exp2_b_multiple_uses(
24-
; CHECK-NEXT: [[T1:%.*]] = call double @llvm.exp2.f64(double [[B:%.*]])
24+
; CHECK-NEXT: [[T1:%.*]] = call reassoc double @llvm.exp2.f64(double [[B:%.*]])
2525
; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc double [[A:%.*]], [[B]]
2626
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.exp2.f64(double [[TMP1]])
2727
; CHECK-NEXT: call void @use(double [[T1]])
2828
; CHECK-NEXT: ret double [[MUL]]
2929
;
30-
%t = call double @llvm.exp2.f64(double %a)
31-
%t1 = call double @llvm.exp2.f64(double %b)
30+
%t = call reassoc double @llvm.exp2.f64(double %a)
31+
%t1 = call reassoc double @llvm.exp2.f64(double %b)
3232
%mul = fmul reassoc double %t, %t1
3333
call void @use(double %t1)
3434
ret double %mul
@@ -40,7 +40,7 @@ define double @exp2_a_a(double %a) {
4040
; CHECK-NEXT: [[M:%.*]] = call reassoc double @llvm.exp2.f64(double [[TMP1]])
4141
; CHECK-NEXT: ret double [[M]]
4242
;
43-
%t = call double @llvm.exp2.f64(double %a)
43+
%t = call reassoc double @llvm.exp2.f64(double %a)
4444
%m = fmul reassoc double %t, %t
4545
ret double %m
4646
}
@@ -70,8 +70,8 @@ define double @exp2_a_exp2_b_reassoc(double %a, double %b) {
7070
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.exp2.f64(double [[TMP1]])
7171
; CHECK-NEXT: ret double [[MUL]]
7272
;
73-
%t = call double @llvm.exp2.f64(double %a)
74-
%t1 = call double @llvm.exp2.f64(double %b)
73+
%t = call reassoc double @llvm.exp2.f64(double %a)
74+
%t1 = call reassoc double @llvm.exp2.f64(double %b)
7575
%mul = fmul reassoc double %t, %t1
7676
ret double %mul
7777
}
@@ -85,12 +85,12 @@ define double @exp2_a_exp2_b_exp2_c_exp2_d(double %a, double %b, double %c, doub
8585
; CHECK-NEXT: [[MUL2:%.*]] = call reassoc double @llvm.exp2.f64(double [[TMP3]])
8686
; CHECK-NEXT: ret double [[MUL2]]
8787
;
88-
%t = call double @llvm.exp2.f64(double %a)
89-
%t1 = call double @llvm.exp2.f64(double %b)
88+
%t = call reassoc double @llvm.exp2.f64(double %a)
89+
%t1 = call reassoc double @llvm.exp2.f64(double %b)
9090
%mul = fmul reassoc double %t, %t1
91-
%t2 = call double @llvm.exp2.f64(double %c)
91+
%t2 = call reassoc double @llvm.exp2.f64(double %c)
9292
%mul1 = fmul reassoc double %mul, %t2
93-
%t3 = call double @llvm.exp2.f64(double %d)
93+
%t3 = call reassoc double @llvm.exp2.f64(double %d)
9494
%mul2 = fmul reassoc double %mul1, %t3
9595
ret double %mul2
9696
}

llvm/test/Transforms/InstCombine/fmul-pow.ll

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ define double @pow_ab_a_reassoc(double %a, double %b) {
2626
; CHECK-NEXT: [[M:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[TMP1]])
2727
; CHECK-NEXT: ret double [[M]]
2828
;
29-
%p = call double @llvm.pow.f64(double %a, double %b)
29+
%p = call reassoc double @llvm.pow.f64(double %a, double %b)
3030
%m = fmul reassoc double %p, %a
3131
ret double %m
3232
}
@@ -35,13 +35,13 @@ define double @pow_ab_a_reassoc(double %a, double %b) {
3535

3636
define double @pow_ab_a_reassoc_commute(double %pa, double %b) {
3737
; CHECK-LABEL: @pow_ab_a_reassoc_commute(
38-
; CHECK-NEXT: [[A:%.*]] = fadd double [[PA:%.*]], 4.200000e+01
38+
; CHECK-NEXT: [[A:%.*]] = fadd reassoc double [[PA:%.*]], 4.200000e+01
3939
; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc double [[B:%.*]], 1.000000e+00
4040
; CHECK-NEXT: [[M:%.*]] = call reassoc double @llvm.pow.f64(double [[A]], double [[TMP1]])
4141
; CHECK-NEXT: ret double [[M]]
4242
;
43-
%a = fadd double %pa, 42.0 ; thwart complexity-based canonicalization
44-
%p = call double @llvm.pow.f64(double %a, double %b)
43+
%a = fadd reassoc double %pa, 42.0 ; thwart complexity-based canonicalization
44+
%p = call reassoc double @llvm.pow.f64(double %a, double %b)
4545
%m = fmul reassoc double %a, %p
4646
ret double %m
4747
}
@@ -85,8 +85,8 @@ define double @pow_ab_recip_a_reassoc(double %a, double %b) {
8585
; CHECK-NEXT: [[M:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[TMP1]])
8686
; CHECK-NEXT: ret double [[M]]
8787
;
88-
%r = fdiv double 1.0, %a
89-
%p = call double @llvm.pow.f64(double %a, double %b)
88+
%r = fdiv reassoc double 1.0, %a
89+
%p = call reassoc double @llvm.pow.f64(double %a, double %b)
9090
%m = fmul reassoc double %r, %p
9191
ret double %m
9292
}
@@ -99,8 +99,8 @@ define double @pow_ab_recip_a_reassoc_commute(double %a, double %b) {
9999
; CHECK-NEXT: [[M:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[TMP1]])
100100
; CHECK-NEXT: ret double [[M]]
101101
;
102-
%r = fdiv double 1.0, %a
103-
%p = call double @llvm.pow.f64(double %a, double %b)
102+
%r = fdiv reassoc double 1.0, %a
103+
%p = call reassoc double @llvm.pow.f64(double %a, double %b)
104104
%m = fmul reassoc double %p, %r
105105
ret double %m
106106
}
@@ -126,13 +126,13 @@ define double @pow_ab_recip_a_reassoc_use1(double %a, double %b) {
126126

127127
define double @pow_ab_recip_a_reassoc_use2(double %a, double %b) {
128128
; CHECK-LABEL: @pow_ab_recip_a_reassoc_use2(
129-
; CHECK-NEXT: [[P:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
129+
; CHECK-NEXT: [[P:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
130130
; CHECK-NEXT: [[M:%.*]] = fdiv reassoc double [[P]], [[A]]
131131
; CHECK-NEXT: call void @use(double [[P]])
132132
; CHECK-NEXT: ret double [[M]]
133133
;
134-
%r = fdiv double 1.0, %a
135-
%p = call double @llvm.pow.f64(double %a, double %b)
134+
%r = fdiv reassoc double 1.0, %a
135+
%p = call reassoc double @llvm.pow.f64(double %a, double %b)
136136
%m = fmul reassoc double %r, %p
137137
call void @use(double %p)
138138
ret double %m
@@ -181,8 +181,8 @@ define double @pow_ab_pow_cb_reassoc(double %a, double %b, double %c) {
181181
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.pow.f64(double [[TMP1]], double [[B:%.*]])
182182
; CHECK-NEXT: ret double [[MUL]]
183183
;
184-
%1 = call double @llvm.pow.f64(double %a, double %b)
185-
%2 = call double @llvm.pow.f64(double %c, double %b)
184+
%1 = call reassoc double @llvm.pow.f64(double %a, double %b)
185+
%2 = call reassoc double @llvm.pow.f64(double %c, double %b)
186186
%mul = fmul reassoc double %2, %1
187187
ret double %mul
188188
}
@@ -191,14 +191,14 @@ define double @pow_ab_pow_cb_reassoc(double %a, double %b, double %c) {
191191

192192
define double @pow_ab_pow_cb_reassoc_use1(double %a, double %b, double %c) {
193193
; CHECK-LABEL: @pow_ab_pow_cb_reassoc_use1(
194-
; CHECK-NEXT: [[AB:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
194+
; CHECK-NEXT: [[AB:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
195195
; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc double [[A]], [[C:%.*]]
196196
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.pow.f64(double [[TMP1]], double [[B]])
197197
; CHECK-NEXT: call void @use(double [[AB]])
198198
; CHECK-NEXT: ret double [[MUL]]
199199
;
200-
%ab = call double @llvm.pow.f64(double %a, double %b)
201-
%cb = call double @llvm.pow.f64(double %c, double %b)
200+
%ab = call reassoc double @llvm.pow.f64(double %a, double %b)
201+
%cb = call reassoc double @llvm.pow.f64(double %c, double %b)
202202
%mul = fmul reassoc double %ab, %cb
203203
call void @use(double %ab)
204204
ret double %mul
@@ -208,14 +208,14 @@ define double @pow_ab_pow_cb_reassoc_use1(double %a, double %b, double %c) {
208208

209209
define double @pow_ab_pow_cb_reassoc_use2(double %a, double %b, double %c) {
210210
; CHECK-LABEL: @pow_ab_pow_cb_reassoc_use2(
211-
; CHECK-NEXT: [[CB:%.*]] = call double @llvm.pow.f64(double [[C:%.*]], double [[B:%.*]])
211+
; CHECK-NEXT: [[CB:%.*]] = call reassoc double @llvm.pow.f64(double [[C:%.*]], double [[B:%.*]])
212212
; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc double [[A:%.*]], [[C]]
213213
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.pow.f64(double [[TMP1]], double [[B]])
214214
; CHECK-NEXT: call void @use(double [[CB]])
215215
; CHECK-NEXT: ret double [[MUL]]
216216
;
217-
%ab = call double @llvm.pow.f64(double %a, double %b)
218-
%cb = call double @llvm.pow.f64(double %c, double %b)
217+
%ab = call reassoc double @llvm.pow.f64(double %a, double %b)
218+
%cb = call reassoc double @llvm.pow.f64(double %c, double %b)
219219
%mul = fmul reassoc double %ab, %cb
220220
call void @use(double %cb)
221221
ret double %mul
@@ -259,8 +259,8 @@ define double @pow_ab_x_pow_ac_reassoc(double %a, double %b, double %c) {
259259
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[TMP1]])
260260
; CHECK-NEXT: ret double [[MUL]]
261261
;
262-
%1 = call double @llvm.pow.f64(double %a, double %b)
263-
%2 = call double @llvm.pow.f64(double %a, double %c)
262+
%1 = call reassoc double @llvm.pow.f64(double %a, double %b)
263+
%2 = call reassoc double @llvm.pow.f64(double %a, double %c)
264264
%mul = fmul reassoc double %2, %1
265265
ret double %mul
266266
}
@@ -271,7 +271,7 @@ define double @pow_ab_reassoc(double %a, double %b) {
271271
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[TMP1]])
272272
; CHECK-NEXT: ret double [[MUL]]
273273
;
274-
%1 = call double @llvm.pow.f64(double %a, double %b)
274+
%1 = call reassoc double @llvm.pow.f64(double %a, double %b)
275275
%mul = fmul reassoc double %1, %1
276276
ret double %mul
277277
}
@@ -291,14 +291,14 @@ define double @pow_ab_reassoc_extra_use(double %a, double %b) {
291291

292292
define double @pow_ab_x_pow_ac_reassoc_extra_use(double %a, double %b, double %c) {
293293
; CHECK-LABEL: @pow_ab_x_pow_ac_reassoc_extra_use(
294-
; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
294+
; CHECK-NEXT: [[TMP1:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
295295
; CHECK-NEXT: [[TMP2:%.*]] = fadd reassoc double [[B]], [[C:%.*]]
296296
; CHECK-NEXT: [[MUL:%.*]] = call reassoc double @llvm.pow.f64(double [[A]], double [[TMP2]])
297297
; CHECK-NEXT: call void @use(double [[TMP1]])
298298
; CHECK-NEXT: ret double [[MUL]]
299299
;
300-
%1 = call double @llvm.pow.f64(double %a, double %b)
301-
%2 = call double @llvm.pow.f64(double %a, double %c)
300+
%1 = call reassoc double @llvm.pow.f64(double %a, double %b)
301+
%2 = call reassoc double @llvm.pow.f64(double %a, double %c)
302302
%mul = fmul reassoc double %1, %2
303303
call void @use(double %1)
304304
ret double %mul

llvm/test/Transforms/InstCombine/fmul-sqrt.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ define double @sqrt_a_sqrt_b_reassoc_nnan(double %a, double %b) {
4545
; CHECK-NEXT: [[MUL:%.*]] = call reassoc nnan double @llvm.sqrt.f64(double [[TMP1]])
4646
; CHECK-NEXT: ret double [[MUL]]
4747
;
48-
%1 = call double @llvm.sqrt.f64(double %a)
49-
%2 = call double @llvm.sqrt.f64(double %b)
48+
%1 = call reassoc double @llvm.sqrt.f64(double %a)
49+
%2 = call reassoc double @llvm.sqrt.f64(double %b)
5050
%mul = fmul reassoc nnan double %1, %2
5151
ret double %mul
5252
}
@@ -78,10 +78,10 @@ define double @sqrt_a_sqrt_b_sqrt_c_sqrt_d_reassoc(double %a, double %b, double
7878
; CHECK-NEXT: [[MUL2:%.*]] = call reassoc nnan ninf double @llvm.sqrt.f64(double [[TMP3]])
7979
; CHECK-NEXT: ret double [[MUL2]]
8080
;
81-
%1 = call double @llvm.sqrt.f64(double %a)
82-
%2 = call double @llvm.sqrt.f64(double %b)
83-
%3 = call double @llvm.sqrt.f64(double %c)
84-
%4 = call double @llvm.sqrt.f64(double %d)
81+
%1 = call reassoc double @llvm.sqrt.f64(double %a)
82+
%2 = call reassoc double @llvm.sqrt.f64(double %b)
83+
%3 = call reassoc double @llvm.sqrt.f64(double %c)
84+
%4 = call reassoc double @llvm.sqrt.f64(double %d)
8585
%mul = fmul reassoc nnan arcp double %1, %2
8686
%mul1 = fmul reassoc nnan double %mul, %3
8787
%mul2 = fmul reassoc nnan ninf double %mul1, %4
@@ -102,13 +102,13 @@ define double @rsqrt_squared(double %x) {
102102
define double @rsqrt_x_reassociate_extra_use(double %x, ptr %p) {
103103
; CHECK-LABEL: @rsqrt_x_reassociate_extra_use(
104104
; CHECK-NEXT: [[SQRT:%.*]] = call double @llvm.sqrt.f64(double [[X:%.*]])
105-
; CHECK-NEXT: [[RSQRT:%.*]] = fdiv double 1.000000e+00, [[SQRT]]
105+
; CHECK-NEXT: [[RSQRT:%.*]] = fdiv reassoc double 1.000000e+00, [[SQRT]]
106106
; CHECK-NEXT: [[RES:%.*]] = fdiv reassoc nsz double [[X]], [[SQRT]]
107107
; CHECK-NEXT: store double [[RSQRT]], ptr [[P:%.*]], align 8
108108
; CHECK-NEXT: ret double [[RES]]
109109
;
110110
%sqrt = call double @llvm.sqrt.f64(double %x)
111-
%rsqrt = fdiv double 1.0, %sqrt
111+
%rsqrt = fdiv reassoc double 1.0, %sqrt
112112
%res = fmul reassoc nsz double %rsqrt, %x
113113
store double %rsqrt, ptr %p
114114
ret double %res
@@ -138,7 +138,7 @@ define double @sqrt_divisor_squared(double %x, double %y) {
138138
; CHECK-NEXT: ret double [[SQUARED]]
139139
;
140140
%sqrt = call double @llvm.sqrt.f64(double %x)
141-
%div = fdiv double %y, %sqrt
141+
%div = fdiv reassoc double %y, %sqrt
142142
%squared = fmul reassoc nnan nsz double %div, %div
143143
ret double %squared
144144
}

0 commit comments

Comments
 (0)