Skip to content

Commit d4eda9c

Browse files
committed
[InstCombine][FP] Fix nnan preserve for xfrm fcmp + sel => fmax/fmin
Preserve `nnan` constraint only if present on both the instructions: `fcmp` and `select`. Alive2: https://alive2.llvm.org/ce/z/ZNDjzt
1 parent 0a44b24 commit d4eda9c

File tree

6 files changed

+45
-37
lines changed

6 files changed

+45
-37
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,17 +3864,25 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
38643864
if (SIFPOp) {
38653865
// TODO: Try to forward-propagate FMF from select arms to the select.
38663866

3867+
auto *FCmp = dyn_cast<FCmpInst>(CondVal);
3868+
38673869
// Canonicalize select of FP values where NaN and -0.0 are not valid as
38683870
// minnum/maxnum intrinsics.
38693871
if (SIFPOp->hasNoNaNs() && SIFPOp->hasNoSignedZeros()) {
38703872
Value *X, *Y;
3871-
if (match(&SI, m_OrdOrUnordFMax(m_Value(X), m_Value(Y))))
3872-
return replaceInstUsesWith(
3873-
SI, Builder.CreateBinaryIntrinsic(Intrinsic::maxnum, X, Y, &SI));
3873+
if (match(&SI, m_OrdOrUnordFMax(m_Value(X), m_Value(Y)))) {
3874+
Value *BinIntr =
3875+
Builder.CreateBinaryIntrinsic(Intrinsic::maxnum, X, Y, &SI);
3876+
cast<Instruction>(BinIntr)->setHasNoNaNs(FCmp->hasNoNaNs());
3877+
return replaceInstUsesWith(SI, BinIntr);
3878+
}
38743879

3875-
if (match(&SI, m_OrdOrUnordFMin(m_Value(X), m_Value(Y))))
3876-
return replaceInstUsesWith(
3877-
SI, Builder.CreateBinaryIntrinsic(Intrinsic::minnum, X, Y, &SI));
3880+
if (match(&SI, m_OrdOrUnordFMin(m_Value(X), m_Value(Y)))) {
3881+
Value *BinIntr =
3882+
Builder.CreateBinaryIntrinsic(Intrinsic::minnum, X, Y, &SI);
3883+
cast<Instruction>(BinIntr)->setHasNoNaNs(FCmp->hasNoNaNs());
3884+
return replaceInstUsesWith(SI, BinIntr);
3885+
}
38783886
}
38793887
}
38803888

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)