minmax-fp.ll 15.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine < %s | FileCheck %s

; This is the canonical form for a type-changing min/max.
define double @t1(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t1(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp oge float [[A:%.*]], 5.000000e+00
; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[DOTINV]], float 5.000000e+00, float [[A]]
; CHECK-NEXT:    [[TMP2:%.*]] = fpext float [[TMP1]] to double
; CHECK-NEXT:    ret double [[TMP2]]
;
  %1 = fcmp ult float %a, 5.0
  %2 = select i1 %1, float %a, float 5.0
  %3 = fpext float %2 to double
  ret double %3
}

; Check this is converted into canonical form, as above.
define double @t2(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t2(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp oge float [[A:%.*]], 5.000000e+00
; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[DOTINV]], float 5.000000e+00, float [[A]]
; CHECK-NEXT:    [[TMP2:%.*]] = fpext float [[TMP1]] to double
; CHECK-NEXT:    ret double [[TMP2]]
;
  %1 = fcmp ult float %a, 5.0
  %2 = fpext float %a to double
  %3 = select i1 %1, double %2, double 5.0
  ret double %3
}

; Same again, with trunc.
define float @t4(double %a) {
; CHECK-LABEL: define {{[^@]+}}@t4(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp oge double [[A:%.*]], 5.000000e+00
; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[DOTINV]], double 5.000000e+00, double [[A]]
; CHECK-NEXT:    [[TMP2:%.*]] = fptrunc double [[TMP1]] to float
; CHECK-NEXT:    ret float [[TMP2]]
;
  %1 = fcmp ult double %a, 5.0
  %2 = fptrunc double %a to float
  %3 = select i1 %1, float %2, float 5.0
  ret float %3
}

; different values, should not be converted.
define double @t5(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t5(
; CHECK-NEXT:    [[TMP1:%.*]] = fcmp ult float [[A:%.*]], 5.000000e+00
; CHECK-NEXT:    [[TMP2:%.*]] = fpext float [[A]] to double
; CHECK-NEXT:    [[TMP3:%.*]] = select i1 [[TMP1]], double [[TMP2]], double 5.001000e+00
; CHECK-NEXT:    ret double [[TMP3]]
;
  %1 = fcmp ult float %a, 5.0
  %2 = fpext float %a to double
  %3 = select i1 %1, double %2, double 5.001
  ret double %3
}

; From IEEE754: "Comparisons shall ignore the sign of zero (so +0 = -0)."
; So the compare constant may be treated as +0.0, and we sink the fpext.

define double @t6(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t6(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp oge float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[DOTINV]], float 0.000000e+00, float [[A]]
; CHECK-NEXT:    [[TMP2:%.*]] = fpext float [[TMP1]] to double
; CHECK-NEXT:    ret double [[TMP2]]
;
  %1 = fcmp ult float %a, -0.0
  %2 = fpext float %a to double
  %3 = select i1 %1, double %2, double 0.0
  ret double %3
}

; From IEEE754: "Comparisons shall ignore the sign of zero (so +0 = -0)."
; So the compare constant may be treated as -0.0, and we sink the fpext.

define double @t7(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t7(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp oge float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[DOTINV]], float -0.000000e+00, float [[A]]
; CHECK-NEXT:    [[TMP2:%.*]] = fpext float [[TMP1]] to double
; CHECK-NEXT:    ret double [[TMP2]]
;
  %1 = fcmp ult float %a, 0.0
  %2 = fpext float %a to double
  %3 = select i1 %1, double %2, double -0.0
  ret double %3
}

; min(min(x, 0.0), 0.0) --> min(x, 0.0)

define float @fmin_fmin_zero_mismatch(float %x) {
; CHECK-LABEL: define {{[^@]+}}@fmin_fmin_zero_mismatch(
; CHECK-NEXT:    [[TMP1:%.*]] = fcmp olt float [[X:%.*]], 0.000000e+00
; CHECK-NEXT:    [[MIN2:%.*]] = select i1 [[TMP1]], float [[X]], float 0.000000e+00
; CHECK-NEXT:    ret float [[MIN2]]
;
  %cmp1 = fcmp olt float %x, -0.0
  %min1 = select i1 %cmp1, float %x, float 0.0
  %cmp2 = fcmp olt float %min1, 0.0
  %min2 = select i1 %cmp2, float %min1, float 0.0
  ret float %min2
}

; max(max(x, -0.0), -0.0) --> max(x, -0.0)

define float @fmax_fmax_zero_mismatch(float %x) {
; CHECK-LABEL: define {{[^@]+}}@fmax_fmax_zero_mismatch(
; CHECK-NEXT:    [[TMP1:%.*]] = fcmp ogt float [[X:%.*]], -0.000000e+00
; CHECK-NEXT:    [[MAX11:%.*]] = select i1 [[TMP1]], float [[X]], float -0.000000e+00
; CHECK-NEXT:    ret float [[MAX11]]
;
  %cmp1 = fcmp ogt float %x, 0.0
  %max1 = select i1 %cmp1, float %x, float -0.0
  %cmp2 = fcmp ogt float 0.0, %max1
  %max2 = select i1 %cmp2, float -0.0, float %max1
  ret float %max2
}

define i64 @t8(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t8(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp oge float [[A:%.*]], 5.000000e+00
; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[DOTINV]], float 5.000000e+00, float [[A]]
; CHECK-NEXT:    [[TMP2:%.*]] = fptoui float [[TMP1]] to i64
; CHECK-NEXT:    ret i64 [[TMP2]]
;
  %1 = fcmp ult float %a, 5.0
  %2 = fptoui float %a to i64
  %3 = select i1 %1, i64 %2, i64 5
  ret i64 %3
}

define i8 @t9(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t9(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp oge float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[DOTINV]], float 0.000000e+00, float [[A]]
; CHECK-NEXT:    [[TMP2:%.*]] = fptosi float [[TMP1]] to i8
; CHECK-NEXT:    ret i8 [[TMP2]]
;
  %1 = fcmp ult float %a, 0.0
  %2 = fptosi float %a to i8
  %3 = select i1 %1, i8 %2, i8 0
  ret i8 %3
}

  ; Either operand could be NaN, but fast modifier applied.
define i8 @t11(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@t11(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp fast oge float [[B:%.*]], [[A:%.*]]
; CHECK-NEXT:    [[TMP1:%.*]] = select fast i1 [[DOTINV]], float [[A]], float [[B]]
; CHECK-NEXT:    [[TMP2:%.*]] = fptosi float [[TMP1]] to i8
; CHECK-NEXT:    ret i8 [[TMP2]]
;
  %1 = fcmp fast ult float %b, %a
  %2 = fptosi float %a to i8
  %3 = fptosi float %b to i8
  %4 = select i1 %1, i8 %3, i8 %2
  ret i8 %4
}

; Either operand could be NaN, but nnan modifier applied.
define i8 @t12(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@t12(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp nnan oge float [[B:%.*]], [[A:%.*]]
; CHECK-NEXT:    [[TMP1:%.*]] = select nnan i1 [[DOTINV]], float [[A]], float [[B]]
; CHECK-NEXT:    [[TMP2:%.*]] = fptosi float [[TMP1]] to i8
; CHECK-NEXT:    ret i8 [[TMP2]]
;
  %1 = fcmp nnan ult float %b, %a
  %2 = fptosi float %a to i8
  %3 = fptosi float %b to i8
  %4 = select i1 %1, i8 %3, i8 %2
  ret i8 %4
}

; Float and int values do not match.
define i8 @t13(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t13(
; CHECK-NEXT:    [[TMP1:%.*]] = fcmp ult float [[A:%.*]], 1.500000e+00
; CHECK-NEXT:    [[TMP2:%.*]] = fptosi float [[A]] to i8
; CHECK-NEXT:    [[TMP3:%.*]] = select i1 [[TMP1]], i8 [[TMP2]], i8 1
; CHECK-NEXT:    ret i8 [[TMP3]]
;
  %1 = fcmp ult float %a, 1.5
  %2 = fptosi float %a to i8
  %3 = select i1 %1, i8 %2, i8 1
  ret i8 %3
}

; %a could be -0.0, but it doesn't matter because the conversion to int is the same for 0.0 or -0.0.
define i8 @t14(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t14(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp oge float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[DOTINV]], float 0.000000e+00, float [[A]]
; CHECK-NEXT:    [[TMP2:%.*]] = fptosi float [[TMP1]] to i8
; CHECK-NEXT:    ret i8 [[TMP2]]
;
  %1 = fcmp ule float %a, 0.0
  %2 = fptosi float %a to i8
  %3 = select i1 %1, i8 %2, i8 0
  ret i8 %3
}

define i8 @t14_commute(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t14_commute(
; CHECK-NEXT:    [[TMP1:%.*]] = fcmp ogt float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    [[TMP2:%.*]] = select i1 [[TMP1]], float [[A]], float 0.000000e+00
; CHECK-NEXT:    [[TMP3:%.*]] = fptosi float [[TMP2]] to i8
; CHECK-NEXT:    ret i8 [[TMP3]]
;
  %1 = fcmp ule float %a, 0.0
  %2 = fptosi float %a to i8
  %3 = select i1 %1, i8 0, i8 %2
  ret i8 %3
}

define i8 @t15(float %a) {
; CHECK-LABEL: define {{[^@]+}}@t15(
; CHECK-NEXT:    [[DOTINV:%.*]] = fcmp nsz oge float [[A:%.*]], 0.000000e+00
; CHECK-NEXT:    [[TMP1:%.*]] = select nsz i1 [[DOTINV]], float 0.000000e+00, float [[A]]
; CHECK-NEXT:    [[TMP2:%.*]] = fptosi float [[TMP1]] to i8
; CHECK-NEXT:    ret i8 [[TMP2]]
;
  %1 = fcmp nsz ule float %a, 0.0
  %2 = fptosi float %a to i8
  %3 = select i1 %1, i8 %2, i8 0
  ret i8 %3
}

define double @t16(i32 %x) {
; CHECK-LABEL: define {{[^@]+}}@t16(
; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
; CHECK-NEXT:    [[CST:%.*]] = sitofp i32 [[X]] to double
; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[CMP]], double [[CST]], double 5.000000e-01
; CHECK-NEXT:    ret double [[SEL]]
;
  %cmp = icmp sgt i32 %x, 0
  %cst = sitofp i32 %x to double
  %sel = select i1 %cmp, double %cst, double 5.000000e-01
  ret double %sel
}

define double @t17(i32 %x) {
; CHECK-LABEL: define {{[^@]+}}@t17(
; CHECK-NEXT:    [[TMP1:%.*]] = icmp sgt i32 [[X:%.*]], 2
; CHECK-NEXT:    [[SEL1:%.*]] = select i1 [[TMP1]], i32 [[X]], i32 2
; CHECK-NEXT:    [[TMP2:%.*]] = sitofp i32 [[SEL1]] to double
; CHECK-NEXT:    ret double [[TMP2]]
;
  %cmp = icmp sgt i32 %x, 2
  %cst = sitofp i32 %x to double
  %sel = select i1 %cmp, double %cst, double 2.0
  ret double %sel
}

define float @fneg_fmax(float %x, float %y) {
; CHECK-LABEL: define {{[^@]+}}@fneg_fmax(
; CHECK-NEXT:    [[COND:%.*]] = fcmp nnan olt float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    [[MAX_V:%.*]] = select i1 [[COND]], float [[X]], float [[Y]]
; CHECK-NEXT:    [[MAX:%.*]] = fneg float [[MAX_V]]
; CHECK-NEXT:    ret float [[MAX]]
;
  %n1 = fneg float %x
  %n2 = fneg float %y
  %cond = fcmp nnan ogt float %n1, %n2
  %max = select i1 %cond, float %n1, float %n2
  ret float %max
}

define <2 x float> @fsub_fmax(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: define {{[^@]+}}@fsub_fmax(
; CHECK-NEXT:    [[COND_INV:%.*]] = fcmp nnan nsz ogt <2 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    [[TMP1:%.*]] = select nnan nsz <2 x i1> [[COND_INV]], <2 x float> [[Y]], <2 x float> [[X]]
; CHECK-NEXT:    [[MAX:%.*]] = fneg <2 x float> [[TMP1]]
; CHECK-NEXT:    ret <2 x float> [[MAX]]
;
  %n1 = fsub <2 x float> <float -0.0, float -0.0>, %x
  %n2 = fsub <2 x float> <float -0.0, float -0.0>, %y
  %cond = fcmp nsz nnan uge <2 x float> %n1, %n2
  %max = select <2 x i1> %cond, <2 x float> %n1, <2 x float> %n2
  ret <2 x float> %max
}

define <2 x double> @fsub_fmin(<2 x double> %x, <2 x double> %y) {
; CHECK-LABEL: define {{[^@]+}}@fsub_fmin(
; CHECK-NEXT:    [[COND:%.*]] = fcmp nnan ogt <2 x double> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    [[MAX_V:%.*]] = select <2 x i1> [[COND]], <2 x double> [[X]], <2 x double> [[Y]]
; CHECK-NEXT:    [[MAX:%.*]] = fneg <2 x double> [[MAX_V]]
; CHECK-NEXT:    ret <2 x double> [[MAX]]
;
  %n1 = fsub <2 x double> <double -0.0, double -0.0>, %x
  %n2 = fsub <2 x double> <double -0.0, double -0.0>, %y
  %cond = fcmp nnan olt <2 x double> %n1, %n2
  %max = select <2 x i1> %cond, <2 x double> %n1, <2 x double> %n2
  ret <2 x double> %max
}

define double @fneg_fmin(double %x, double %y) {
; CHECK-LABEL: define {{[^@]+}}@fneg_fmin(
; CHECK-NEXT:    [[COND_INV:%.*]] = fcmp nnan nsz olt double [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    [[TMP1:%.*]] = select nnan nsz i1 [[COND_INV]], double [[Y]], double [[X]]
; CHECK-NEXT:    [[MAX:%.*]] = fneg double [[TMP1]]
; CHECK-NEXT:    ret double [[MAX]]
;
  %n1 = fneg double %x
  %n2 = fneg double %y
  %cond = fcmp nsz nnan ule double %n1, %n2
  %max = select i1 %cond, double %n1, double %n2
  ret double %max
}

define float @maxnum_ogt_fmf_on_select(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@maxnum_ogt_fmf_on_select(
; CHECK-NEXT:    [[TMP1:%.*]] = call nnan nsz float @llvm.maxnum.f32(float [[A:%.*]], float [[B:%.*]])
; CHECK-NEXT:    ret float [[TMP1]]
;
  %cond = fcmp ogt float %a, %b
  %f = select nnan nsz i1 %cond, float %a, float %b
  ret float %f
}

define <2 x float> @maxnum_oge_fmf_on_select(<2 x float> %a, <2 x float> %b) {
; CHECK-LABEL: define {{[^@]+}}@maxnum_oge_fmf_on_select(
; CHECK-NEXT:    [[TMP1:%.*]] = call nnan ninf nsz <2 x float> @llvm.maxnum.v2f32(<2 x float> [[A:%.*]], <2 x float> [[B:%.*]])
; CHECK-NEXT:    ret <2 x float> [[TMP1]]
;
  %cond = fcmp oge <2 x float> %a, %b
  %f = select ninf nnan nsz <2 x i1> %cond, <2 x float> %a, <2 x float> %b
  ret <2 x float> %f
}

define float @maxnum_ogt_fmf_on_fcmp(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@maxnum_ogt_fmf_on_fcmp(
; CHECK-NEXT:    [[COND:%.*]] = fcmp nnan nsz ogt float [[A:%.*]], [[B:%.*]]
; CHECK-NEXT:    [[F:%.*]] = select i1 [[COND]], float [[A]], float [[B]]
; CHECK-NEXT:    ret float [[F]]
;
  %cond = fcmp nnan nsz ogt float %a, %b
  %f = select i1 %cond, float %a, float %b
  ret float %f
}

define <2 x float> @maxnum_oge_fmf_on_fcmp(<2 x float> %a, <2 x float> %b) {
; CHECK-LABEL: define {{[^@]+}}@maxnum_oge_fmf_on_fcmp(
; CHECK-NEXT:    [[COND:%.*]] = fcmp nnan ninf nsz oge <2 x float> [[A:%.*]], [[B:%.*]]
; CHECK-NEXT:    [[F:%.*]] = select <2 x i1> [[COND]], <2 x float> [[A]], <2 x float> [[B]]
; CHECK-NEXT:    ret <2 x float> [[F]]
;
  %cond = fcmp ninf nnan nsz oge <2 x float> %a, %b
  %f = select <2 x i1> %cond, <2 x float> %a, <2 x float> %b
  ret <2 x float> %f
}

define float @maxnum_no_nsz(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@maxnum_no_nsz(
; CHECK-NEXT:    [[COND:%.*]] = fcmp ogt float [[A:%.*]], [[B:%.*]]
; CHECK-NEXT:    [[F:%.*]] = select nnan i1 [[COND]], float [[A]], float [[B]]
; CHECK-NEXT:    ret float [[F]]
;
  %cond = fcmp ogt float %a, %b
  %f = select nnan i1 %cond, float %a, float %b
  ret float %f
}

define float @maxnum_no_nnan(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@maxnum_no_nnan(
; CHECK-NEXT:    [[COND:%.*]] = fcmp oge float [[A:%.*]], [[B:%.*]]
; CHECK-NEXT:    [[F:%.*]] = select nsz i1 [[COND]], float [[A]], float [[B]]
; CHECK-NEXT:    ret float [[F]]
;
  %cond = fcmp oge float %a, %b
  %f = select nsz i1 %cond, float %a, float %b
  ret float %f
}

define float @minnum_olt_fmf_on_select(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@minnum_olt_fmf_on_select(
; CHECK-NEXT:    [[TMP1:%.*]] = call nnan nsz float @llvm.minnum.f32(float [[A:%.*]], float [[B:%.*]])
; CHECK-NEXT:    ret float [[TMP1]]
;
  %cond = fcmp olt float %a, %b
  %f = select nnan nsz i1 %cond, float %a, float %b
  ret float %f
}

define <2 x float> @minnum_ole_fmf_on_select(<2 x float> %a, <2 x float> %b) {
; CHECK-LABEL: define {{[^@]+}}@minnum_ole_fmf_on_select(
; CHECK-NEXT:    [[TMP1:%.*]] = call nnan ninf nsz <2 x float> @llvm.minnum.v2f32(<2 x float> [[A:%.*]], <2 x float> [[B:%.*]])
; CHECK-NEXT:    ret <2 x float> [[TMP1]]
;
  %cond = fcmp ole <2 x float> %a, %b
  %f = select ninf nnan nsz <2 x i1> %cond, <2 x float> %a, <2 x float> %b
  ret <2 x float> %f
}

define float @minnum_olt_fmf_on_fcmp(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@minnum_olt_fmf_on_fcmp(
; CHECK-NEXT:    [[COND:%.*]] = fcmp nnan nsz olt float [[A:%.*]], [[B:%.*]]
; CHECK-NEXT:    [[F:%.*]] = select i1 [[COND]], float [[A]], float [[B]]
; CHECK-NEXT:    ret float [[F]]
;
  %cond = fcmp nnan nsz olt float %a, %b
  %f = select i1 %cond, float %a, float %b
  ret float %f
}

define <2 x float> @minnum_ole_fmf_on_fcmp(<2 x float> %a, <2 x float> %b) {
; CHECK-LABEL: define {{[^@]+}}@minnum_ole_fmf_on_fcmp(
; CHECK-NEXT:    [[COND:%.*]] = fcmp nnan ninf nsz ole <2 x float> [[A:%.*]], [[B:%.*]]
; CHECK-NEXT:    [[F:%.*]] = select <2 x i1> [[COND]], <2 x float> [[A]], <2 x float> [[B]]
; CHECK-NEXT:    ret <2 x float> [[F]]
;
  %cond = fcmp ninf nnan nsz ole <2 x float> %a, %b
  %f = select <2 x i1> %cond, <2 x float> %a, <2 x float> %b
  ret <2 x float> %f
}

define float @minnum_no_nsz(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@minnum_no_nsz(
; CHECK-NEXT:    [[COND:%.*]] = fcmp olt float [[A:%.*]], [[B:%.*]]
; CHECK-NEXT:    [[F:%.*]] = select nnan i1 [[COND]], float [[A]], float [[B]]
; CHECK-NEXT:    ret float [[F]]
;
  %cond = fcmp olt float %a, %b
  %f = select nnan i1 %cond, float %a, float %b
  ret float %f
}

define float @minnum_no_nnan(float %a, float %b) {
; CHECK-LABEL: define {{[^@]+}}@minnum_no_nnan(
; CHECK-NEXT:    [[COND:%.*]] = fcmp ole float [[A:%.*]], [[B:%.*]]
; CHECK-NEXT:    [[F:%.*]] = select nsz i1 [[COND]], float [[A]], float [[B]]
; CHECK-NEXT:    ret float [[F]]
;
  %cond = fcmp ole float %a, %b
  %f = select nsz i1 %cond, float %a, float %b
  ret float %f
}