2017-06-13 01:31:36 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2016-10-06 07:20:32 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s
|
2007-07-02 23:43:20 +08:00
|
|
|
|
|
|
|
declare double @sin(double %f)
|
|
|
|
|
2016-10-06 07:20:32 +08:00
|
|
|
; When the subs are strict, they can't be removed because of signed zero.
|
|
|
|
|
|
|
|
define double @strict(double %e) nounwind {
|
|
|
|
; CHECK-LABEL: strict:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2016-10-06 07:20:32 +08:00
|
|
|
; CHECK-NEXT: pushq %rax
|
|
|
|
; CHECK-NEXT: vxorpd %xmm1, %xmm1, %xmm1
|
|
|
|
; CHECK-NEXT: vsubsd %xmm0, %xmm1, %xmm0
|
|
|
|
; CHECK-NEXT: callq sin
|
|
|
|
; CHECK-NEXT: vxorpd %xmm1, %xmm1, %xmm1
|
|
|
|
; CHECK-NEXT: vsubsd %xmm0, %xmm1, %xmm0
|
|
|
|
; CHECK-NEXT: popq %rax
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%f = fsub double 0.0, %e
|
|
|
|
%g = call double @sin(double %f) readonly
|
|
|
|
%h = fsub double 0.0, %g
|
|
|
|
ret double %h
|
|
|
|
}
|
|
|
|
|
|
|
|
; 'fast' implies no-signed-zeros, so the negates fold away.
|
|
|
|
; The 'sin' does not need any fast-math-flags for this transform.
|
|
|
|
|
|
|
|
define double @fast(double %e) nounwind {
|
|
|
|
; CHECK-LABEL: fast:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2018-03-10 10:42:14 +08:00
|
|
|
; CHECK-NEXT: jmp sin # TAILCALL
|
2016-10-06 07:20:32 +08:00
|
|
|
%f = fsub fast double 0.0, %e
|
|
|
|
%g = call double @sin(double %f) readonly
|
|
|
|
%h = fsub fast double 0.0, %g
|
|
|
|
ret double %h
|
|
|
|
}
|
|
|
|
|
|
|
|
; No-signed-zeros is all that we need for this transform.
|
|
|
|
|
|
|
|
define double @nsz(double %e) nounwind {
|
|
|
|
; CHECK-LABEL: nsz:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2018-03-10 10:42:14 +08:00
|
|
|
; CHECK-NEXT: jmp sin # TAILCALL
|
2016-10-06 07:20:32 +08:00
|
|
|
%f = fsub nsz double 0.0, %e
|
|
|
|
%g = call double @sin(double %f) readonly
|
|
|
|
%h = fsub nsz double 0.0, %g
|
|
|
|
ret double %h
|
|
|
|
}
|
|
|
|
|
|
|
|
; The 1st negate is strict, so we can't kill that sub, but the 2nd disappears.
|
|
|
|
|
|
|
|
define double @semi_strict1(double %e) nounwind {
|
|
|
|
; CHECK-LABEL: semi_strict1:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2016-10-06 07:20:32 +08:00
|
|
|
; CHECK-NEXT: pushq %rax
|
|
|
|
; CHECK-NEXT: vxorpd %xmm1, %xmm1, %xmm1
|
|
|
|
; CHECK-NEXT: vsubsd %xmm0, %xmm1, %xmm0
|
|
|
|
; CHECK-NEXT: callq sin
|
2016-10-21 22:36:58 +08:00
|
|
|
; CHECK-NEXT: vxorpd {{.*}}(%rip), %xmm0, %xmm0
|
2016-10-06 07:20:32 +08:00
|
|
|
; CHECK-NEXT: popq %rax
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%f = fsub double 0.0, %e
|
|
|
|
%g = call double @sin(double %f) readonly
|
|
|
|
%h = fsub nsz double 0.0, %g
|
|
|
|
ret double %h
|
|
|
|
}
|
|
|
|
|
|
|
|
; The 2nd negate is strict, so we can't kill it. It becomes an add of zero instead.
|
|
|
|
|
|
|
|
define double @semi_strict2(double %e) nounwind {
|
|
|
|
; CHECK-LABEL: semi_strict2:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2016-10-06 07:20:32 +08:00
|
|
|
; CHECK-NEXT: pushq %rax
|
|
|
|
; CHECK-NEXT: callq sin
|
|
|
|
; CHECK-NEXT: vxorpd %xmm1, %xmm1, %xmm1
|
2016-10-21 22:36:58 +08:00
|
|
|
; CHECK-NEXT: vaddsd %xmm1, %xmm0, %xmm0
|
2016-10-06 07:20:32 +08:00
|
|
|
; CHECK-NEXT: popq %rax
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%f = fsub nsz double 0.0, %e
|
|
|
|
%g = call double @sin(double %f) readonly
|
|
|
|
%h = fsub double 0.0, %g
|
|
|
|
ret double %h
|
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME:
|
|
|
|
; Auto-upgrade function attribute to IR-level fast-math-flags.
|
|
|
|
|
|
|
|
define double @fn_attr(double %e) nounwind #0 {
|
|
|
|
; CHECK-LABEL: fn_attr:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2018-03-10 10:42:14 +08:00
|
|
|
; CHECK-NEXT: jmp sin # TAILCALL
|
2009-06-05 06:49:04 +08:00
|
|
|
%f = fsub double 0.0, %e
|
2009-09-26 02:15:29 +08:00
|
|
|
%g = call double @sin(double %f) readonly
|
2009-06-05 06:49:04 +08:00
|
|
|
%h = fsub double 0.0, %g
|
2007-07-02 23:43:20 +08:00
|
|
|
ret double %h
|
|
|
|
}
|
2016-10-06 05:43:50 +08:00
|
|
|
|
2017-01-25 14:08:42 +08:00
|
|
|
attributes #0 = { "unsafe-fp-math"="true" "no-signed-zeros-fp-math"="true" }
|
2016-10-06 05:43:50 +08:00
|
|
|
|