2016-09-21 03:31:30 +08:00
|
|
|
; RUN: llc -mtriple=x86_64-apple-macosx10.10.0 < %s | FileCheck %s
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
|
|
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
; The assertions are *enhanced* from update_test_checks.ll to include
|
2016-09-24 07:17:29 +08:00
|
|
|
; the constant load values because those are important.
|
2016-09-21 03:31:30 +08:00
|
|
|
|
|
|
|
; CHECK: [[SIGNMASK1:L.+]]:
|
2015-12-08 10:37:48 +08:00
|
|
|
; CHECK-NEXT: .quad -9223372036854775808 ## double -0
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: .quad -9223372036854775808 ## double -0
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
define double @mag_pos0_double(double %x) nounwind {
|
|
|
|
; CHECK-LABEL: mag_pos0_double:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: andps [[SIGNMASK1]](%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
;
|
|
|
|
%y = call double @copysign(double 0.0, double %x)
|
|
|
|
ret double %y
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
}
|
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[SIGNMASK2:L.+]]:
|
|
|
|
; CHECK-NEXT: .quad -9223372036854775808 ## double -0
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
define double @mag_neg0_double(double %x) nounwind {
|
|
|
|
; CHECK-LABEL: mag_neg0_double:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: movsd [[SIGNMASK2]](%rip), %xmm1
|
2016-09-28 06:28:13 +08:00
|
|
|
; CHECK-NEXT: andps %xmm1, %xmm0
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
;
|
|
|
|
%y = call double @copysign(double -0.0, double %x)
|
|
|
|
ret double %y
|
|
|
|
}
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[SIGNMASK3:L.+]]:
|
|
|
|
; CHECK-NEXT: .quad -9223372036854775808 ## double -0
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: .quad -9223372036854775808 ## double -0
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[ONE3:L.+]]:
|
|
|
|
; CHECK-NEXT: .quad 4607182418800017408 ## double 1
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
define double @mag_pos1_double(double %x) nounwind {
|
|
|
|
; CHECK-LABEL: mag_pos1_double:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: andps [[SIGNMASK3]](%rip), %xmm0
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: movsd [[ONE3]](%rip), %xmm1
|
|
|
|
; CHECK-NEXT: movlhps {{.*#+}} xmm1 = xmm1[0,0]
|
|
|
|
; CHECK-NEXT: orps %xmm1, %xmm0
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
;
|
|
|
|
%y = call double @copysign(double 1.0, double %x)
|
|
|
|
ret double %y
|
|
|
|
}
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[SIGNMASK4:L.+]]:
|
|
|
|
; CHECK-NEXT: .quad -9223372036854775808 ## double -0
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: .quad -9223372036854775808 ## double -0
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[ONE4:L.+]]:
|
|
|
|
; CHECK-NEXT: .quad 4607182418800017408 ## double 1
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: .quad 4607182418800017408 ## double 1
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
define double @mag_neg1_double(double %x) nounwind {
|
|
|
|
; CHECK-LABEL: mag_neg1_double:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: andps [[SIGNMASK4]](%rip), %xmm0
|
|
|
|
; CHECK-NEXT: orps [[ONE4]](%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
;
|
|
|
|
%y = call double @copysign(double -1.0, double %x)
|
|
|
|
ret double %y
|
|
|
|
}
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[SIGNMASK5:L.+]]:
|
|
|
|
; CHECK-NEXT: .long 2147483648 ## float -0
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: .long 2147483648 ## float -0
|
2016-09-21 03:31:30 +08:00
|
|
|
|
|
|
|
define float @mag_pos0_float(float %x) nounwind {
|
|
|
|
; CHECK-LABEL: mag_pos0_float:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: andps [[SIGNMASK5]](%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
;
|
|
|
|
%y = call float @copysignf(float 0.0, float %x)
|
|
|
|
ret float %y
|
|
|
|
}
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[SIGNMASK6:L.+]]:
|
|
|
|
; CHECK-NEXT: .long 2147483648 ## float -0
|
|
|
|
|
|
|
|
define float @mag_neg0_float(float %x) nounwind {
|
|
|
|
; CHECK-LABEL: mag_neg0_float:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: movss [[SIGNMASK6]](%rip), %xmm1
|
2016-09-28 06:28:13 +08:00
|
|
|
; CHECK-NEXT: andps %xmm1, %xmm0
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
;
|
|
|
|
%y = call float @copysignf(float -0.0, float %x)
|
|
|
|
ret float %y
|
|
|
|
}
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[SIGNMASK7:L.+]]:
|
|
|
|
; CHECK-NEXT: .long 2147483648 ## float -0
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: .long 2147483648 ## float -0
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[ONE7:L.+]]:
|
|
|
|
; CHECK-NEXT: .long 1065353216 ## float 1
|
|
|
|
|
|
|
|
define float @mag_pos1_float(float %x) nounwind {
|
|
|
|
; CHECK-LABEL: mag_pos1_float:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: andps [[SIGNMASK7]](%rip), %xmm0
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: movss [[ONE7]](%rip), %xmm1
|
|
|
|
; CHECK-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0,0,0]
|
|
|
|
; CHECK-NEXT: orps %xmm1, %xmm0
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
;
|
|
|
|
%y = call float @copysignf(float 1.0, float %x)
|
|
|
|
ret float %y
|
|
|
|
}
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[SIGNMASK8:L.+]]:
|
|
|
|
; CHECK-NEXT: .long 2147483648 ## float -0
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: .long 2147483648 ## float -0
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK: [[ONE8:L.+]]:
|
|
|
|
; CHECK-NEXT: .long 1065353216 ## float 1
|
2016-09-24 07:17:29 +08:00
|
|
|
; CHECK-NEXT: .long 1065353216 ## float 1
|
|
|
|
; CHECK-NEXT: .long 1065353216 ## float 1
|
|
|
|
; CHECK-NEXT: .long 1065353216 ## float 1
|
2016-09-21 03:31:30 +08:00
|
|
|
|
|
|
|
define float @mag_neg1_float(float %x) nounwind {
|
|
|
|
; CHECK-LABEL: mag_neg1_float:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-09-21 03:31:30 +08:00
|
|
|
; CHECK-NEXT: andps [[SIGNMASK8]](%rip), %xmm0
|
|
|
|
; CHECK-NEXT: orps [[ONE8]](%rip), %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
;
|
|
|
|
%y = call float @copysignf(float -1.0, float %x)
|
|
|
|
ret float %y
|
[X86] Teach FCOPYSIGN lowering to recognize constant magnitudes.
For code like:
float foo(float x) { return copysign(1.0, x); }
We used to generate:
andps <-0.000000e+00,0,0,0>, %xmm0
movss <1.000000e+00>, %xmm1
andps <nan>, %xmm1
orps %xmm0, %xmm1
Basically doing an abs(1.0f) in the two middle instructions.
We now generate:
andps <-0.000000e+00,0,0,0>, %xmm0
orps <1.000000e+00,0,0,0>, %xmm0
Builds on cleanups r223415, r223542.
rdar://19049548
Differential Revision: http://reviews.llvm.org/D6555
llvm-svn: 225357
2015-01-08 01:33:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
declare double @copysign(double, double) nounwind readnone
|
|
|
|
declare float @copysignf(float, float) nounwind readnone
|
|
|
|
|