2015-11-24 05:33:58 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2015-08-08 05:42:24 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -enable-unsafe-fp-math | FileCheck %s
|
2012-04-08 04:04:00 +08:00
|
|
|
|
|
|
|
define double @exact(double %x) {
|
2012-04-09 02:08:12 +08:00
|
|
|
; Exact division by a constant converted to multiplication.
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-LABEL: exact:
|
2015-08-08 05:42:24 +08:00
|
|
|
; CHECK: # BB#0:
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-NEXT: mulsd {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
2012-04-08 04:04:00 +08:00
|
|
|
%div = fdiv double %x, 2.0
|
|
|
|
ret double %div
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @inexact(double %x) {
|
2012-04-09 02:08:12 +08:00
|
|
|
; Inexact division by a constant converted to multiplication.
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-LABEL: inexact:
|
2015-08-08 05:42:24 +08:00
|
|
|
; CHECK: # BB#0:
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-NEXT: mulsd {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%div = fdiv double %x, 0x41DFFFFFFFC00000
|
2012-04-08 04:04:00 +08:00
|
|
|
ret double %div
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @funky(double %x) {
|
|
|
|
; No conversion to multiplication if too funky.
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-LABEL: funky:
|
2015-08-08 05:42:24 +08:00
|
|
|
; CHECK: # BB#0:
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-NEXT: xorpd %xmm1, %xmm1
|
|
|
|
; CHECK-NEXT: divsd %xmm1, %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
2012-04-08 04:04:00 +08:00
|
|
|
%div = fdiv double %x, 0.0
|
|
|
|
ret double %div
|
|
|
|
}
|
2012-04-11 04:35:27 +08:00
|
|
|
|
|
|
|
define double @denormal1(double %x) {
|
|
|
|
; Don't generate multiplication by a denormal.
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-LABEL: denormal1:
|
2015-08-08 05:42:24 +08:00
|
|
|
; CHECK: # BB#0:
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-NEXT: divsd {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
2012-04-11 04:35:27 +08:00
|
|
|
%div = fdiv double %x, 0x7FD0000000000001
|
|
|
|
ret double %div
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @denormal2(double %x) {
|
|
|
|
; Don't generate multiplication by a denormal.
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-LABEL: denormal2:
|
2015-08-08 05:42:24 +08:00
|
|
|
; CHECK: # BB#0:
|
2015-08-08 05:38:53 +08:00
|
|
|
; CHECK-NEXT: divsd {{.*}}(%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
2012-04-11 04:35:27 +08:00
|
|
|
%div = fdiv double %x, 0x7FEFFFFFFFFFFFFF
|
|
|
|
ret double %div
|
|
|
|
}
|
2015-08-08 05:38:53 +08:00
|
|
|
|
2015-08-08 07:19:41 +08:00
|
|
|
; Deleting the negates does not require unsafe-fp-math.
|
|
|
|
|
|
|
|
define float @double_negative(float %x, float %y) #0 {
|
|
|
|
; CHECK-LABEL: double_negative:
|
|
|
|
; CHECK: # BB#0:
|
|
|
|
; CHECK-NEXT: divss %xmm1, %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%neg1 = fsub float -0.0, %x
|
|
|
|
%neg2 = fsub float -0.0, %y
|
|
|
|
%div = fdiv float %neg1, %neg2
|
|
|
|
ret float %div
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { "unsafe-fp-math"="false" }
|
|
|
|
|