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 -enable-unsafe-fp-math | FileCheck %s
      3 
      4 define double @exact(double %x) {
      5 ; Exact division by a constant converted to multiplication.
      6 ; CHECK-LABEL: exact:
      7 ; CHECK:       # BB#0:
      8 ; CHECK-NEXT:    mulsd {{.*}}(%rip), %xmm0
      9 ; CHECK-NEXT:    retq
     10   %div = fdiv double %x, 2.0
     11   ret double %div
     12 }
     13 
     14 define double @inexact(double %x) {
     15 ; Inexact division by a constant converted to multiplication.
     16 ; CHECK-LABEL: inexact:
     17 ; CHECK:       # BB#0:
     18 ; CHECK-NEXT:    mulsd {{.*}}(%rip), %xmm0
     19 ; CHECK-NEXT:    retq
     20   %div = fdiv double %x, 0x41DFFFFFFFC00000
     21   ret double %div
     22 }
     23 
     24 define double @funky(double %x) {
     25 ; No conversion to multiplication if too funky.
     26 ; CHECK-LABEL: funky:
     27 ; CHECK:       # BB#0:
     28 ; CHECK-NEXT:    xorpd %xmm1, %xmm1
     29 ; CHECK-NEXT:    divsd %xmm1, %xmm0
     30 ; CHECK-NEXT:    retq
     31   %div = fdiv double %x, 0.0
     32   ret double %div
     33 }
     34 
     35 define double @denormal1(double %x) {
     36 ; Don't generate multiplication by a denormal.
     37 ; CHECK-LABEL: denormal1:
     38 ; CHECK:       # BB#0:
     39 ; CHECK-NEXT:    divsd {{.*}}(%rip), %xmm0
     40 ; CHECK-NEXT:    retq
     41   %div = fdiv double %x, 0x7FD0000000000001
     42   ret double %div
     43 }
     44 
     45 define double @denormal2(double %x) {
     46 ; Don't generate multiplication by a denormal.
     47 ; CHECK-LABEL: denormal2:
     48 ; CHECK:       # BB#0:
     49 ; CHECK-NEXT:    divsd {{.*}}(%rip), %xmm0
     50 ; CHECK-NEXT:    retq
     51   %div = fdiv double %x, 0x7FEFFFFFFFFFFFFF
     52   ret double %div
     53 }
     54 
     55 ; Deleting the negates does not require unsafe-fp-math.
     56 
     57 define float @double_negative(float %x, float %y) #0 {
     58 ; CHECK-LABEL: double_negative:
     59 ; CHECK:       # BB#0:
     60 ; CHECK-NEXT:    divss %xmm1, %xmm0
     61 ; CHECK-NEXT:    retq
     62   %neg1 = fsub float -0.0, %x
     63   %neg2 = fsub float -0.0, %y
     64   %div = fdiv float %neg1, %neg2
     65   ret float %div
     66 }
     67 
     68 attributes #0 = { "unsafe-fp-math"="false" }
     69 
     70