Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown                        | FileCheck %s --check-prefixes=ANY,STRICT
      3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -enable-unsafe-fp-math | FileCheck %s --check-prefixes=ANY,UNSAFE
      4 
      5 ; This is duplicated from tests for InstSimplify. If you're
      6 ; adding something here, you should probably add it there too.
      7 
      8 define float @fadd_undef_op0(float %x) {
      9 ; ANY-LABEL: fadd_undef_op0:
     10 ; ANY:       # %bb.0:
     11 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     12 ; ANY-NEXT:    retq
     13   %r = fadd float undef, %x
     14   ret float %r
     15 }
     16 
     17 define float @fadd_undef_op1(float %x) {
     18 ; ANY-LABEL: fadd_undef_op1:
     19 ; ANY:       # %bb.0:
     20 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     21 ; ANY-NEXT:    retq
     22   %r = fadd float %x, undef
     23   ret float %r
     24 }
     25 
     26 define float @fsub_undef_op0(float %x) {
     27 ; ANY-LABEL: fsub_undef_op0:
     28 ; ANY:       # %bb.0:
     29 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     30 ; ANY-NEXT:    retq
     31   %r = fsub float undef, %x
     32   ret float %r
     33 }
     34 
     35 define float @fsub_undef_op1(float %x) {
     36 ; ANY-LABEL: fsub_undef_op1:
     37 ; ANY:       # %bb.0:
     38 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     39 ; ANY-NEXT:    retq
     40   %r = fsub float %x, undef
     41   ret float %r
     42 }
     43 
     44 define float @fmul_undef_op0(float %x) {
     45 ; ANY-LABEL: fmul_undef_op0:
     46 ; ANY:       # %bb.0:
     47 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     48 ; ANY-NEXT:    retq
     49   %r = fmul float undef, %x
     50   ret float %r
     51 }
     52 
     53 define float @fmul_undef_op1(float %x) {
     54 ; ANY-LABEL: fmul_undef_op1:
     55 ; ANY:       # %bb.0:
     56 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     57 ; ANY-NEXT:    retq
     58   %r = fmul float %x, undef
     59   ret float %r
     60 }
     61 
     62 define float @fdiv_undef_op0(float %x) {
     63 ; ANY-LABEL: fdiv_undef_op0:
     64 ; ANY:       # %bb.0:
     65 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     66 ; ANY-NEXT:    retq
     67   %r = fdiv float undef, %x
     68   ret float %r
     69 }
     70 
     71 define float @fdiv_undef_op1(float %x) {
     72 ; ANY-LABEL: fdiv_undef_op1:
     73 ; ANY:       # %bb.0:
     74 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     75 ; ANY-NEXT:    retq
     76   %r = fdiv float %x, undef
     77   ret float %r
     78 }
     79 
     80 define float @frem_undef_op0(float %x) {
     81 ; ANY-LABEL: frem_undef_op0:
     82 ; ANY:       # %bb.0:
     83 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     84 ; ANY-NEXT:    retq
     85   %r = frem float undef, %x
     86   ret float %r
     87 }
     88 
     89 define float @frem_undef_op1(float %x) {
     90 ; ANY-LABEL: frem_undef_op1:
     91 ; ANY:       # %bb.0:
     92 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     93 ; ANY-NEXT:    retq
     94   %r = frem float %x, undef
     95   ret float %r
     96 }
     97 
     98 ; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage.
     99 
    100 define float @fadd_undef_op0_nnan(float %x) {
    101 ; ANY-LABEL: fadd_undef_op0_nnan:
    102 ; ANY:       # %bb.0:
    103 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    104 ; ANY-NEXT:    retq
    105   %r = fadd nnan float undef, %x
    106   ret float %r
    107 }
    108 
    109 define float @fadd_undef_op1_fast(float %x) {
    110 ; ANY-LABEL: fadd_undef_op1_fast:
    111 ; ANY:       # %bb.0:
    112 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    113 ; ANY-NEXT:    retq
    114   %r = fadd fast float %x, undef
    115   ret float %r
    116 }
    117 
    118 define float @fsub_undef_op0_fast(float %x) {
    119 ; ANY-LABEL: fsub_undef_op0_fast:
    120 ; ANY:       # %bb.0:
    121 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    122 ; ANY-NEXT:    retq
    123   %r = fsub fast float undef, %x
    124   ret float %r
    125 }
    126 
    127 define float @fsub_undef_op1_nnan(float %x) {
    128 ; ANY-LABEL: fsub_undef_op1_nnan:
    129 ; ANY:       # %bb.0:
    130 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    131 ; ANY-NEXT:    retq
    132   %r = fsub nnan float %x, undef
    133   ret float %r
    134 }
    135 
    136 define float @fmul_undef_op0_nnan(float %x) {
    137 ; ANY-LABEL: fmul_undef_op0_nnan:
    138 ; ANY:       # %bb.0:
    139 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    140 ; ANY-NEXT:    retq
    141   %r = fmul nnan float undef, %x
    142   ret float %r
    143 }
    144 
    145 define float @fmul_undef_op1_fast(float %x) {
    146 ; ANY-LABEL: fmul_undef_op1_fast:
    147 ; ANY:       # %bb.0:
    148 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    149 ; ANY-NEXT:    retq
    150   %r = fmul fast float %x, undef
    151   ret float %r
    152 }
    153 
    154 define float @fdiv_undef_op0_fast(float %x) {
    155 ; ANY-LABEL: fdiv_undef_op0_fast:
    156 ; ANY:       # %bb.0:
    157 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    158 ; ANY-NEXT:    retq
    159   %r = fdiv fast float undef, %x
    160   ret float %r
    161 }
    162 
    163 define float @fdiv_undef_op1_nnan(float %x) {
    164 ; ANY-LABEL: fdiv_undef_op1_nnan:
    165 ; ANY:       # %bb.0:
    166 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    167 ; ANY-NEXT:    retq
    168   %r = fdiv nnan float %x, undef
    169   ret float %r
    170 }
    171 
    172 define float @frem_undef_op0_nnan(float %x) {
    173 ; ANY-LABEL: frem_undef_op0_nnan:
    174 ; ANY:       # %bb.0:
    175 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    176 ; ANY-NEXT:    retq
    177   %r = frem nnan float undef, %x
    178   ret float %r
    179 }
    180 
    181 define float @frem_undef_op1_fast(float %x) {
    182 ; ANY-LABEL: frem_undef_op1_fast:
    183 ; ANY:       # %bb.0:
    184 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    185 ; ANY-NEXT:    retq
    186   %r = frem fast float %x, undef
    187   ret float %r
    188 }
    189 
    190 ; Constant folding - undef undef.
    191 
    192 define double @fadd_undef_undef(double %x) {
    193 ; ANY-LABEL: fadd_undef_undef:
    194 ; ANY:       # %bb.0:
    195 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    196 ; ANY-NEXT:    retq
    197   %r = fadd double undef, undef
    198   ret double %r
    199 }
    200 
    201 define double @fsub_undef_undef(double %x) {
    202 ; ANY-LABEL: fsub_undef_undef:
    203 ; ANY:       # %bb.0:
    204 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    205 ; ANY-NEXT:    retq
    206   %r = fsub double undef, undef
    207   ret double %r
    208 }
    209 
    210 define double @fmul_undef_undef(double %x) {
    211 ; ANY-LABEL: fmul_undef_undef:
    212 ; ANY:       # %bb.0:
    213 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    214 ; ANY-NEXT:    retq
    215   %r = fmul double undef, undef
    216   ret double %r
    217 }
    218 
    219 define double @fdiv_undef_undef(double %x) {
    220 ; ANY-LABEL: fdiv_undef_undef:
    221 ; ANY:       # %bb.0:
    222 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    223 ; ANY-NEXT:    retq
    224   %r = fdiv double undef, undef
    225   ret double %r
    226 }
    227 
    228 define double @frem_undef_undef(double %x) {
    229 ; ANY-LABEL: frem_undef_undef:
    230 ; ANY:       # %bb.0:
    231 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    232 ; ANY-NEXT:    retq
    233   %r = frem double undef, undef
    234   ret double %r
    235 }
    236 
    237 ; Constant folding.
    238 
    239 define float @fadd_undef_op0_nnan_constant(float %x) {
    240 ; ANY-LABEL: fadd_undef_op0_nnan_constant:
    241 ; ANY:       # %bb.0:
    242 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    243 ; ANY-NEXT:    retq
    244   %r = fadd nnan float undef, 1.0
    245   ret float %r
    246 }
    247 
    248 define float @fadd_undef_op1_constant(float %x) {
    249 ; ANY-LABEL: fadd_undef_op1_constant:
    250 ; ANY:       # %bb.0:
    251 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    252 ; ANY-NEXT:    retq
    253   %r = fadd float 2.0, undef
    254   ret float %r
    255 }
    256 
    257 define float @fsub_undef_op0_fast_constant(float %x) {
    258 ; ANY-LABEL: fsub_undef_op0_fast_constant:
    259 ; ANY:       # %bb.0:
    260 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    261 ; ANY-NEXT:    retq
    262   %r = fsub fast float undef, 3.0
    263   ret float %r
    264 }
    265 
    266 define float @fsub_undef_op1_constant(float %x) {
    267 ; ANY-LABEL: fsub_undef_op1_constant:
    268 ; ANY:       # %bb.0:
    269 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    270 ; ANY-NEXT:    retq
    271   %r = fsub float 4.0, undef
    272   ret float %r
    273 }
    274 
    275 define float @fmul_undef_op0_nnan_constant(float %x) {
    276 ; ANY-LABEL: fmul_undef_op0_nnan_constant:
    277 ; ANY:       # %bb.0:
    278 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    279 ; ANY-NEXT:    retq
    280   %r = fmul nnan float undef, 5.0
    281   ret float %r
    282 }
    283 
    284 define float @fmul_undef_op1_constant(float %x) {
    285 ; ANY-LABEL: fmul_undef_op1_constant:
    286 ; ANY:       # %bb.0:
    287 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    288 ; ANY-NEXT:    retq
    289   %r = fmul float 6.0, undef
    290   ret float %r
    291 }
    292 
    293 define float @fdiv_undef_op0_fast_constant(float %x) {
    294 ; ANY-LABEL: fdiv_undef_op0_fast_constant:
    295 ; ANY:       # %bb.0:
    296 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    297 ; ANY-NEXT:    retq
    298   %r = fdiv fast float undef, 7.0
    299   ret float %r
    300 }
    301 
    302 define float @fdiv_undef_op1_constant(float %x) {
    303 ; ANY-LABEL: fdiv_undef_op1_constant:
    304 ; ANY:       # %bb.0:
    305 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    306 ; ANY-NEXT:    retq
    307   %r = fdiv float 8.0, undef
    308   ret float %r
    309 }
    310 
    311 define float @frem_undef_op0_nnan_constant(float %x) {
    312 ; ANY-LABEL: frem_undef_op0_nnan_constant:
    313 ; ANY:       # %bb.0:
    314 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    315 ; ANY-NEXT:    retq
    316   %r = frem nnan float undef, 9.0
    317   ret float %r
    318 }
    319 
    320 define float @frem_undef_op1_constant(float %x) {
    321 ; ANY-LABEL: frem_undef_op1_constant:
    322 ; ANY:       # %bb.0:
    323 ; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    324 ; ANY-NEXT:    retq
    325   %r = frem float 10.0, undef
    326   ret float %r
    327 }
    328 
    329 ; Constant folding - special constants: NaN.
    330 
    331 define double @fadd_undef_op0_constant_nan(double %x) {
    332 ; ANY-LABEL: fadd_undef_op0_constant_nan:
    333 ; ANY:       # %bb.0:
    334 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    335 ; ANY-NEXT:    retq
    336   %r = fadd double undef, 0x7FF8000000000000
    337   ret double %r
    338 }
    339 
    340 define double @fadd_undef_op1_fast_constant_nan(double %x) {
    341 ; ANY-LABEL: fadd_undef_op1_fast_constant_nan:
    342 ; ANY:       # %bb.0:
    343 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    344 ; ANY-NEXT:    retq
    345   %r = fadd fast double 0xFFF0000000000001, undef
    346   ret double %r
    347 }
    348 
    349 define double @fsub_undef_op0_constant_nan(double %x) {
    350 ; ANY-LABEL: fsub_undef_op0_constant_nan:
    351 ; ANY:       # %bb.0:
    352 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    353 ; ANY-NEXT:    retq
    354   %r = fsub double undef, 0xFFF8000000000010
    355   ret double %r
    356 }
    357 
    358 define double @fsub_undef_op1_nnan_constant_nan(double %x) {
    359 ; ANY-LABEL: fsub_undef_op1_nnan_constant_nan:
    360 ; ANY:       # %bb.0:
    361 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    362 ; ANY-NEXT:    retq
    363   %r = fsub nnan double 0x7FF0000000000011, undef
    364   ret double %r
    365 }
    366 
    367 define double @fmul_undef_op0_constant_nan(double %x) {
    368 ; ANY-LABEL: fmul_undef_op0_constant_nan:
    369 ; ANY:       # %bb.0:
    370 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    371 ; ANY-NEXT:    retq
    372   %r = fmul double undef, 0x7FF8000000000100
    373   ret double %r
    374 }
    375 
    376 define double @fmul_undef_op1_fast_constant_nan(double %x) {
    377 ; ANY-LABEL: fmul_undef_op1_fast_constant_nan:
    378 ; ANY:       # %bb.0:
    379 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    380 ; ANY-NEXT:    retq
    381   %r = fmul fast double 0xFFF0000000000101, undef
    382   ret double %r
    383 }
    384 
    385 define double @fdiv_undef_op0_constant_nan(double %x) {
    386 ; ANY-LABEL: fdiv_undef_op0_constant_nan:
    387 ; ANY:       # %bb.0:
    388 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    389 ; ANY-NEXT:    retq
    390   %r = fdiv double undef, 0xFFF8000000000110
    391   ret double %r
    392 }
    393 
    394 define double @fdiv_undef_op1_nnan_constant_nan(double %x) {
    395 ; ANY-LABEL: fdiv_undef_op1_nnan_constant_nan:
    396 ; ANY:       # %bb.0:
    397 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    398 ; ANY-NEXT:    retq
    399   %r = fdiv nnan double 0x7FF0000000000111, undef
    400   ret double %r
    401 }
    402 
    403 define double @frem_undef_op0_constant_nan(double %x) {
    404 ; ANY-LABEL: frem_undef_op0_constant_nan:
    405 ; ANY:       # %bb.0:
    406 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    407 ; ANY-NEXT:    retq
    408   %r = frem double undef, 0x7FF8000000001000
    409   ret double %r
    410 }
    411 
    412 define double @frem_undef_op1_fast_constant_nan(double %x) {
    413 ; ANY-LABEL: frem_undef_op1_fast_constant_nan:
    414 ; ANY:       # %bb.0:
    415 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    416 ; ANY-NEXT:    retq
    417   %r = frem fast double 0xFFF0000000001001, undef
    418   ret double %r
    419 }
    420 
    421 ; Constant folding - special constants: Inf.
    422 
    423 define double @fadd_undef_op0_constant_inf(double %x) {
    424 ; ANY-LABEL: fadd_undef_op0_constant_inf:
    425 ; ANY:       # %bb.0:
    426 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    427 ; ANY-NEXT:    retq
    428   %r = fadd double undef, 0x7FF0000000000000
    429   ret double %r
    430 }
    431 
    432 define double @fadd_undef_op1_fast_constant_inf(double %x) {
    433 ; ANY-LABEL: fadd_undef_op1_fast_constant_inf:
    434 ; ANY:       # %bb.0:
    435 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    436 ; ANY-NEXT:    retq
    437   %r = fadd fast double 0xFFF0000000000000, undef
    438   ret double %r
    439 }
    440 
    441 define double @fsub_undef_op0_constant_inf(double %x) {
    442 ; ANY-LABEL: fsub_undef_op0_constant_inf:
    443 ; ANY:       # %bb.0:
    444 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    445 ; ANY-NEXT:    retq
    446   %r = fsub double undef, 0xFFF0000000000000
    447   ret double %r
    448 }
    449 
    450 define double @fsub_undef_op1_ninf_constant_inf(double %x) {
    451 ; ANY-LABEL: fsub_undef_op1_ninf_constant_inf:
    452 ; ANY:       # %bb.0:
    453 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    454 ; ANY-NEXT:    retq
    455   %r = fsub ninf double 0x7FF0000000000000, undef
    456   ret double %r
    457 }
    458 
    459 define double @fmul_undef_op0_constant_inf(double %x) {
    460 ; ANY-LABEL: fmul_undef_op0_constant_inf:
    461 ; ANY:       # %bb.0:
    462 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    463 ; ANY-NEXT:    retq
    464   %r = fmul double undef, 0x7FF0000000000000
    465   ret double %r
    466 }
    467 
    468 define double @fmul_undef_op1_fast_constant_inf(double %x) {
    469 ; ANY-LABEL: fmul_undef_op1_fast_constant_inf:
    470 ; ANY:       # %bb.0:
    471 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    472 ; ANY-NEXT:    retq
    473   %r = fmul fast double 0xFFF0000000000000, undef
    474   ret double %r
    475 }
    476 
    477 define double @fdiv_undef_op0_constant_inf(double %x) {
    478 ; ANY-LABEL: fdiv_undef_op0_constant_inf:
    479 ; ANY:       # %bb.0:
    480 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    481 ; ANY-NEXT:    retq
    482   %r = fdiv double undef, 0xFFF0000000000000
    483   ret double %r
    484 }
    485 
    486 define double @fdiv_undef_op1_ninf_constant_inf(double %x) {
    487 ; ANY-LABEL: fdiv_undef_op1_ninf_constant_inf:
    488 ; ANY:       # %bb.0:
    489 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    490 ; ANY-NEXT:    retq
    491   %r = fdiv ninf double 0x7FF0000000000000, undef
    492   ret double %r
    493 }
    494 
    495 define double @frem_undef_op0_constant_inf(double %x) {
    496 ; ANY-LABEL: frem_undef_op0_constant_inf:
    497 ; ANY:       # %bb.0:
    498 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    499 ; ANY-NEXT:    retq
    500   %r = frem double undef, 0x7FF0000000000000
    501   ret double %r
    502 }
    503 
    504 define double @frem_undef_op1_fast_constant_inf(double %x) {
    505 ; ANY-LABEL: frem_undef_op1_fast_constant_inf:
    506 ; ANY:       # %bb.0:
    507 ; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    508 ; ANY-NEXT:    retq
    509   %r = frem fast double 0xFFF0000000000000, undef
    510   ret double %r
    511 }
    512 
    513