Skip to content

Commit de415fb

Browse files
authored
[InstCombine][FP] Fix nnan preservation for transform fcmp + sel => fmax/fmin (llvm#117977)
Preserve `nnan` constraint only if present on both `fcmp` and `select`. Alive2: https://alive2.llvm.org/ce/z/ZNDjzt
1 parent dac9736 commit de415fb

File tree

6 files changed

+47
-37
lines changed

6 files changed

+47
-37
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3897,17 +3897,27 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
38973897
if (SIFPOp) {
38983898
// TODO: Try to forward-propagate FMF from select arms to the select.
38993899

3900+
auto *FCmp = dyn_cast<FCmpInst>(CondVal);
3901+
39003902
// Canonicalize select of FP values where NaN and -0.0 are not valid as
39013903
// minnum/maxnum intrinsics.
39023904
if (SIFPOp->hasNoNaNs() && SIFPOp->hasNoSignedZeros()) {
39033905
Value *X, *Y;
3904-
if (match(&SI, m_OrdOrUnordFMax(m_Value(X), m_Value(Y))))
3905-
return replaceInstUsesWith(
3906-
SI, Builder.CreateBinaryIntrinsic(Intrinsic::maxnum, X, Y, &SI));
3906+
if (match(&SI, m_OrdOrUnordFMax(m_Value(X), m_Value(Y)))) {
3907+
Value *BinIntr =
3908+
Builder.CreateBinaryIntrinsic(Intrinsic::maxnum, X, Y, &SI);
3909+
if (auto *BinIntrInst = dyn_cast<Instruction>(BinIntr))
3910+
BinIntrInst->setHasNoNaNs(FCmp->hasNoNaNs());
3911+
return replaceInstUsesWith(SI, BinIntr);
3912+
}
39073913

3908-
if (match(&SI, m_OrdOrUnordFMin(m_Value(X), m_Value(Y))))
3909-
return replaceInstUsesWith(
3910-
SI, Builder.CreateBinaryIntrinsic(Intrinsic::minnum, X, Y, &SI));
3914+
if (match(&SI, m_OrdOrUnordFMin(m_Value(X), m_Value(Y)))) {
3915+
Value *BinIntr =
3916+
Builder.CreateBinaryIntrinsic(Intrinsic::minnum, X, Y, &SI);
3917+
if (auto *BinIntrInst = dyn_cast<Instruction>(BinIntr))
3918+
BinIntrInst->setHasNoNaNs(FCmp->hasNoNaNs());
3919+
return replaceInstUsesWith(SI, BinIntr);
3920+
}
39113921
}
39123922
}
39133923

llvm/test/Transforms/InstCombine/fcmp-fadd-select.ll

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
define float @test_fcmp_ogt_fadd_select_constant(float %in) {
77
; CHECK-LABEL: define float @test_fcmp_ogt_fadd_select_constant(
88
; CHECK-SAME: float [[IN:%.*]]) {
9-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
9+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
1010
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
1111
; CHECK-NEXT: ret float [[ADD_NEW]]
1212
;
@@ -19,7 +19,7 @@ define float @test_fcmp_ogt_fadd_select_constant(float %in) {
1919
define float @test_fcmp_ogt_fadd_select_constant_swapped(float %in) {
2020
; CHECK-LABEL: define float @test_fcmp_ogt_fadd_select_constant_swapped(
2121
; CHECK-SAME: float [[IN:%.*]]) {
22-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
22+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
2323
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
2424
; CHECK-NEXT: ret float [[ADD_NEW]]
2525
;
@@ -32,7 +32,7 @@ define float @test_fcmp_ogt_fadd_select_constant_swapped(float %in) {
3232
define float @test_fcmp_ogt_fadd_select_neg_constant(float %in) {
3333
; CHECK-LABEL: define float @test_fcmp_ogt_fadd_select_neg_constant(
3434
; CHECK-SAME: float [[IN:%.*]]) {
35-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
35+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
3636
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
3737
; CHECK-NEXT: ret float [[ADD_NEW]]
3838
;
@@ -45,7 +45,7 @@ define float @test_fcmp_ogt_fadd_select_neg_constant(float %in) {
4545
define float @test_fcmp_ogt_fadd_select_fastmath_preserve(float %in) {
4646
; CHECK-LABEL: define float @test_fcmp_ogt_fadd_select_fastmath_preserve(
4747
; CHECK-SAME: float [[IN:%.*]]) {
48-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
48+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
4949
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
5050
; CHECK-NEXT: ret float [[ADD_NEW]]
5151
;
@@ -58,7 +58,7 @@ define float @test_fcmp_ogt_fadd_select_fastmath_preserve(float %in) {
5858
define <2 x float> @test_fcmp_ogt_fadd_select_constant_vectors(<2 x float> %in) {
5959
; CHECK-LABEL: define <2 x float> @test_fcmp_ogt_fadd_select_constant_vectors(
6060
; CHECK-SAME: <2 x float> [[IN:%.*]]) {
61-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz <2 x float> @llvm.maxnum.v2f32(<2 x float> [[IN]], <2 x float> zeroinitializer)
61+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz <2 x float> @llvm.maxnum.v2f32(<2 x float> [[IN]], <2 x float> zeroinitializer)
6262
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz <2 x float> [[SEL_NEW]], splat (float 1.000000e+00)
6363
; CHECK-NEXT: ret <2 x float> [[ADD_NEW]]
6464
;
@@ -74,7 +74,7 @@ define <2 x float> @test_fcmp_ogt_fadd_select_constant_vectors(<2 x float> %in)
7474
define float @test_fcmp_olt_fadd_select_constant(float %in) {
7575
; CHECK-LABEL: define float @test_fcmp_olt_fadd_select_constant(
7676
; CHECK-SAME: float [[IN:%.*]]) {
77-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
77+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
7878
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
7979
; CHECK-NEXT: ret float [[ADD_NEW]]
8080
;
@@ -87,7 +87,7 @@ define float @test_fcmp_olt_fadd_select_constant(float %in) {
8787
define float @test_fcmp_olt_fadd_select_constant_swapped(float %in) {
8888
; CHECK-LABEL: define float @test_fcmp_olt_fadd_select_constant_swapped(
8989
; CHECK-SAME: float [[IN:%.*]]) {
90-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
90+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
9191
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
9292
; CHECK-NEXT: ret float [[ADD_NEW]]
9393
;
@@ -100,7 +100,7 @@ define float @test_fcmp_olt_fadd_select_constant_swapped(float %in) {
100100
define float @test_fcmp_olt_fadd_select_neg_constant(float %in) {
101101
; CHECK-LABEL: define float @test_fcmp_olt_fadd_select_neg_constant(
102102
; CHECK-SAME: float [[IN:%.*]]) {
103-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
103+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
104104
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
105105
; CHECK-NEXT: ret float [[ADD_NEW]]
106106
;
@@ -113,7 +113,7 @@ define float @test_fcmp_olt_fadd_select_neg_constant(float %in) {
113113
define float @test_fcmp_olt_fadd_select_fastmath_preserve(float %in) {
114114
; CHECK-LABEL: define float @test_fcmp_olt_fadd_select_fastmath_preserve(
115115
; CHECK-SAME: float [[IN:%.*]]) {
116-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
116+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
117117
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
118118
; CHECK-NEXT: ret float [[ADD_NEW]]
119119
;
@@ -126,7 +126,7 @@ define float @test_fcmp_olt_fadd_select_fastmath_preserve(float %in) {
126126
define <2 x float> @test_fcmp_olt_fadd_select_constant_vectors(<2 x float> %in) {
127127
; CHECK-LABEL: define <2 x float> @test_fcmp_olt_fadd_select_constant_vectors(
128128
; CHECK-SAME: <2 x float> [[IN:%.*]]) {
129-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz <2 x float> @llvm.minnum.v2f32(<2 x float> [[IN]], <2 x float> zeroinitializer)
129+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz <2 x float> @llvm.minnum.v2f32(<2 x float> [[IN]], <2 x float> zeroinitializer)
130130
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz <2 x float> [[SEL_NEW]], splat (float 1.000000e+00)
131131
; CHECK-NEXT: ret <2 x float> [[ADD_NEW]]
132132
;
@@ -142,7 +142,7 @@ define <2 x float> @test_fcmp_olt_fadd_select_constant_vectors(<2 x float> %in)
142142
define float @test_fcmp_oge_fadd_select_constant(float %in) {
143143
; CHECK-LABEL: define float @test_fcmp_oge_fadd_select_constant(
144144
; CHECK-SAME: float [[IN:%.*]]) {
145-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
145+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
146146
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
147147
; CHECK-NEXT: ret float [[ADD_NEW]]
148148
;
@@ -155,7 +155,7 @@ define float @test_fcmp_oge_fadd_select_constant(float %in) {
155155
define float @test_fcmp_oge_fadd_select_constant_swapped(float %in) {
156156
; CHECK-LABEL: define float @test_fcmp_oge_fadd_select_constant_swapped(
157157
; CHECK-SAME: float [[IN:%.*]]) {
158-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
158+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
159159
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
160160
; CHECK-NEXT: ret float [[ADD_NEW]]
161161
;
@@ -168,7 +168,7 @@ define float @test_fcmp_oge_fadd_select_constant_swapped(float %in) {
168168
define float @test_fcmp_oge_fadd_select_neg_constant(float %in) {
169169
; CHECK-LABEL: define float @test_fcmp_oge_fadd_select_neg_constant(
170170
; CHECK-SAME: float [[IN:%.*]]) {
171-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
171+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
172172
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
173173
; CHECK-NEXT: ret float [[ADD_NEW]]
174174
;
@@ -181,7 +181,7 @@ define float @test_fcmp_oge_fadd_select_neg_constant(float %in) {
181181
define float @test_fcmp_oge_fadd_select_fastmath_preserve(float %in) {
182182
; CHECK-LABEL: define float @test_fcmp_oge_fadd_select_fastmath_preserve(
183183
; CHECK-SAME: float [[IN:%.*]]) {
184-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
184+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
185185
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
186186
; CHECK-NEXT: ret float [[ADD_NEW]]
187187
;
@@ -194,7 +194,7 @@ define float @test_fcmp_oge_fadd_select_fastmath_preserve(float %in) {
194194
define <2 x float> @test_fcmp_oge_fadd_select_constant_vectors(<2 x float> %in) {
195195
; CHECK-LABEL: define <2 x float> @test_fcmp_oge_fadd_select_constant_vectors(
196196
; CHECK-SAME: <2 x float> [[IN:%.*]]) {
197-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz <2 x float> @llvm.maxnum.v2f32(<2 x float> [[IN]], <2 x float> zeroinitializer)
197+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz <2 x float> @llvm.maxnum.v2f32(<2 x float> [[IN]], <2 x float> zeroinitializer)
198198
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz <2 x float> [[SEL_NEW]], splat (float 1.000000e+00)
199199
; CHECK-NEXT: ret <2 x float> [[ADD_NEW]]
200200
;
@@ -210,7 +210,7 @@ define <2 x float> @test_fcmp_oge_fadd_select_constant_vectors(<2 x float> %in)
210210
define float @test_fcmp_ole_fadd_select_constant(float %in) {
211211
; CHECK-LABEL: define float @test_fcmp_ole_fadd_select_constant(
212212
; CHECK-SAME: float [[IN:%.*]]) {
213-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
213+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
214214
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
215215
; CHECK-NEXT: ret float [[ADD_NEW]]
216216
;
@@ -223,7 +223,7 @@ define float @test_fcmp_ole_fadd_select_constant(float %in) {
223223
define float @test_fcmp_ole_fadd_select_constant_swapped(float %in) {
224224
; CHECK-LABEL: define float @test_fcmp_ole_fadd_select_constant_swapped(
225225
; CHECK-SAME: float [[IN:%.*]]) {
226-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
226+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
227227
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
228228
; CHECK-NEXT: ret float [[ADD_NEW]]
229229
;
@@ -236,7 +236,7 @@ define float @test_fcmp_ole_fadd_select_constant_swapped(float %in) {
236236
define float @test_fcmp_ole_fadd_select_neg_constant(float %in) {
237237
; CHECK-LABEL: define float @test_fcmp_ole_fadd_select_neg_constant(
238238
; CHECK-SAME: float [[IN:%.*]]) {
239-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
239+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
240240
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
241241
; CHECK-NEXT: ret float [[ADD_NEW]]
242242
;
@@ -249,7 +249,7 @@ define float @test_fcmp_ole_fadd_select_neg_constant(float %in) {
249249
define float @test_fcmp_ole_fadd_select_fastmath_preserve(float %in) {
250250
; CHECK-LABEL: define float @test_fcmp_ole_fadd_select_fastmath_preserve(
251251
; CHECK-SAME: float [[IN:%.*]]) {
252-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
252+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.minnum.f32(float [[IN]], float 0.000000e+00)
253253
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
254254
; CHECK-NEXT: ret float [[ADD_NEW]]
255255
;
@@ -262,7 +262,7 @@ define float @test_fcmp_ole_fadd_select_fastmath_preserve(float %in) {
262262
define <2 x float> @test_fcmp_ole_fadd_select_constant_vectors(<2 x float> %in) {
263263
; CHECK-LABEL: define <2 x float> @test_fcmp_ole_fadd_select_constant_vectors(
264264
; CHECK-SAME: <2 x float> [[IN:%.*]]) {
265-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz <2 x float> @llvm.minnum.v2f32(<2 x float> [[IN]], <2 x float> zeroinitializer)
265+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz <2 x float> @llvm.minnum.v2f32(<2 x float> [[IN]], <2 x float> zeroinitializer)
266266
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz <2 x float> [[SEL_NEW]], splat (float 1.000000e+00)
267267
; CHECK-NEXT: ret <2 x float> [[ADD_NEW]]
268268
;
@@ -637,7 +637,7 @@ define float @test_fcmp_multiple_uses(float %in) {
637637
define float @test_fcmp_ogt_fadd_select_rewrite_flags1(float %in) {
638638
; CHECK-LABEL: define float @test_fcmp_ogt_fadd_select_rewrite_flags1(
639639
; CHECK-SAME: float [[IN:%.*]]) {
640-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call reassoc nnan nsz arcp contract afn float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
640+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call reassoc nsz arcp contract afn float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
641641
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd reassoc nnan nsz arcp contract afn float [[SEL_NEW]], 1.000000e+00
642642
; CHECK-NEXT: ret float [[ADD_NEW]]
643643
;
@@ -650,7 +650,7 @@ define float @test_fcmp_ogt_fadd_select_rewrite_flags1(float %in) {
650650
define float @test_fcmp_ogt_fadd_select_rewrite_flags2(float %in) {
651651
; CHECK-LABEL: define float @test_fcmp_ogt_fadd_select_rewrite_flags2(
652652
; CHECK-SAME: float [[IN:%.*]]) {
653-
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
653+
; CHECK-NEXT: [[SEL_NEW:%.*]] = call nsz float @llvm.maxnum.f32(float [[IN]], float 0.000000e+00)
654654
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd nnan nsz float [[SEL_NEW]], 1.000000e+00
655655
; CHECK-NEXT: ret float [[ADD_NEW]]
656656
;
@@ -667,7 +667,7 @@ define float @test_fcmp_ogt_fadd_select_rewrite_and_fastmath(float %in) {
667667
; CHECK-NEXT: [[ADD_NEW:%.*]] = fadd fast float [[SEL_NEW]], 1.000000e+00
668668
; CHECK-NEXT: ret float [[ADD_NEW]]
669669
;
670-
%cmp1 = fcmp ogt float %in, 0.000000e+00
670+
%cmp1 = fcmp nnan ogt float %in, 0.000000e+00
671671
%add = fadd fast reassoc float %in, 1.000000e+00
672672
%sel = select fast i1 %cmp1, float %add, float 1.000000e+00
673673
ret float %sel

llvm/test/Transforms/InstCombine/fcmp-select.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ define double @test_fcmp_select_clamp(double %x) {
219219

220220
define double @test_fcmp_select_maxnum(double %x) {
221221
; CHECK-LABEL: @test_fcmp_select_maxnum(
222-
; CHECK-NEXT: [[SEL1:%.*]] = call nnan nsz double @llvm.maxnum.f64(double [[X:%.*]], double 1.000000e+00)
223-
; CHECK-NEXT: [[SEL2:%.*]] = call nnan nsz double @llvm.minnum.f64(double [[SEL1]], double 2.550000e+02)
222+
; CHECK-NEXT: [[SEL1:%.*]] = call nsz double @llvm.maxnum.f64(double [[X:%.*]], double 1.000000e+00)
223+
; CHECK-NEXT: [[SEL2:%.*]] = call nsz double @llvm.minnum.f64(double [[SEL1]], double 2.550000e+02)
224224
; CHECK-NEXT: ret double [[SEL2]]
225225
;
226226
%cmp1 = fcmp ogt double %x, 1.0

llvm/test/Transforms/InstCombine/fneg.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ define float @test_fneg_select_constant_var_multiuse(i1 %cond, float %x) {
10991099

11001100
define float @test_fneg_select_maxnum(float %x) {
11011101
; CHECK-LABEL: @test_fneg_select_maxnum(
1102-
; CHECK-NEXT: [[SEL1:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[X:%.*]], float 1.000000e+00)
1102+
; CHECK-NEXT: [[SEL1:%.*]] = call nsz float @llvm.maxnum.f32(float [[X:%.*]], float 1.000000e+00)
11031103
; CHECK-NEXT: [[NEG:%.*]] = fneg float [[SEL1]]
11041104
; CHECK-NEXT: ret float [[NEG]]
11051105
;

llvm/test/Transforms/InstCombine/minmax-fp.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ define double @fneg_fmin(double %x, double %y) {
321321

322322
define float @maxnum_ogt_fmf_on_select(float %a, float %b) {
323323
; CHECK-LABEL: @maxnum_ogt_fmf_on_select(
324-
; CHECK-NEXT: [[F:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[A:%.*]], float [[B:%.*]])
324+
; CHECK-NEXT: [[F:%.*]] = call nsz float @llvm.maxnum.f32(float [[A:%.*]], float [[B:%.*]])
325325
; CHECK-NEXT: ret float [[F]]
326326
;
327327
%cond = fcmp ogt float %a, %b
@@ -331,7 +331,7 @@ define float @maxnum_ogt_fmf_on_select(float %a, float %b) {
331331

332332
define <2 x float> @maxnum_oge_fmf_on_select(<2 x float> %a, <2 x float> %b) {
333333
; CHECK-LABEL: @maxnum_oge_fmf_on_select(
334-
; CHECK-NEXT: [[F:%.*]] = call nnan ninf nsz <2 x float> @llvm.maxnum.v2f32(<2 x float> [[A:%.*]], <2 x float> [[B:%.*]])
334+
; CHECK-NEXT: [[F:%.*]] = call ninf nsz <2 x float> @llvm.maxnum.v2f32(<2 x float> [[A:%.*]], <2 x float> [[B:%.*]])
335335
; CHECK-NEXT: ret <2 x float> [[F]]
336336
;
337337
%cond = fcmp oge <2 x float> %a, %b
@@ -385,7 +385,7 @@ define float @maxnum_no_nnan(float %a, float %b) {
385385

386386
define float @minnum_olt_fmf_on_select(float %a, float %b) {
387387
; CHECK-LABEL: @minnum_olt_fmf_on_select(
388-
; CHECK-NEXT: [[F:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[A:%.*]], float [[B:%.*]])
388+
; CHECK-NEXT: [[F:%.*]] = call nsz float @llvm.minnum.f32(float [[A:%.*]], float [[B:%.*]])
389389
; CHECK-NEXT: ret float [[F]]
390390
;
391391
%cond = fcmp olt float %a, %b
@@ -395,7 +395,7 @@ define float @minnum_olt_fmf_on_select(float %a, float %b) {
395395

396396
define <2 x float> @minnum_ole_fmf_on_select(<2 x float> %a, <2 x float> %b) {
397397
; CHECK-LABEL: @minnum_ole_fmf_on_select(
398-
; CHECK-NEXT: [[F:%.*]] = call nnan ninf nsz <2 x float> @llvm.minnum.v2f32(<2 x float> [[A:%.*]], <2 x float> [[B:%.*]])
398+
; CHECK-NEXT: [[F:%.*]] = call ninf nsz <2 x float> @llvm.minnum.v2f32(<2 x float> [[A:%.*]], <2 x float> [[B:%.*]])
399399
; CHECK-NEXT: ret <2 x float> [[F]]
400400
;
401401
%cond = fcmp ole <2 x float> %a, %b

llvm/test/Transforms/InstCombine/unordered-fcmp-select.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ define float @select_max_ugt_2_use_cmp(float %a, float %b) {
115115
; CHECK-LABEL: @select_max_ugt_2_use_cmp(
116116
; CHECK-NEXT: [[CMP:%.*]] = fcmp reassoc ugt float [[A:%.*]], [[B:%.*]]
117117
; CHECK-NEXT: call void @foo(i1 [[CMP]])
118-
; CHECK-NEXT: [[SEL:%.*]] = call fast float @llvm.maxnum.f32(float [[A]], float [[B]])
118+
; CHECK-NEXT: [[SEL:%.*]] = call reassoc ninf nsz arcp contract afn float @llvm.maxnum.f32(float [[A]], float [[B]])
119119
; CHECK-NEXT: ret float [[SEL]]
120120
;
121121
%cmp = fcmp reassoc ugt float %a, %b

0 commit comments

Comments
 (0)