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:
|
2017-12-05 01:18:51 +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:
|
2017-12-05 01:18:51 +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:
|
2017-12-05 01:18:51 +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:
|
2017-12-05 01:18:51 +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:
|
2017-12-05 01:18:51 +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:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2015-08-08 07:19:41 +08:00
|
|
|
; 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
|
|
|
|
}
|
|
|
|
|
2019-06-06 02:55:54 +08:00
|
|
|
define <4 x float> @double_negative_vector(<4 x float> %x, <4 x float> %y) #0 {
|
|
|
|
; CHECK-LABEL: double_negative_vector:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: divps %xmm1, %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%neg1 = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %x
|
|
|
|
%neg2 = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %y
|
|
|
|
%div = fdiv <4 x float> %neg1, %neg2
|
|
|
|
ret <4 x float> %div
|
|
|
|
}
|
|
|
|
|
2015-08-08 07:19:41 +08:00
|
|
|
attributes #0 = { "unsafe-fp-math"="false" }
|
|
|
|
|