• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=x86_64-apple-macosx10.10.0 < %s | FileCheck %s
2
3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4
5; The assertions are *enhanced* from update_test_checks.ll to include
6; the constant load values because those are important.
7
8; CHECK:        [[SIGNMASK1:L.+]]:
9; CHECK-NEXT:   .quad -9223372036854775808    ## double -0
10; CHECK-NEXT:   .quad -9223372036854775808    ## double -0
11
12define double @mag_pos0_double(double %x) nounwind {
13; CHECK-LABEL: mag_pos0_double:
14; CHECK:       ## %bb.0:
15; CHECK-NEXT:    andps [[SIGNMASK1]](%rip), %xmm0
16; CHECK-NEXT:    retq
17;
18  %y = call double @copysign(double 0.0, double %x)
19  ret double %y
20}
21
22; CHECK:        [[SIGNMASK2:L.+]]:
23; CHECK-NEXT:   .quad -9223372036854775808    ## double -0
24
25define double @mag_neg0_double(double %x) nounwind {
26; CHECK-LABEL: mag_neg0_double:
27; CHECK:       ## %bb.0:
28; CHECK-NEXT:    movsd [[SIGNMASK2]](%rip), %xmm1
29; CHECK-NEXT:    movlhps {{.*#+}} xmm1 = xmm1[0,0]
30; CHECK-NEXT:    andps %xmm1, %xmm0
31; CHECK-NEXT:    retq
32;
33  %y = call double @copysign(double -0.0, double %x)
34  ret double %y
35}
36
37; CHECK:        [[SIGNMASK3:L.+]]:
38; CHECK-NEXT:   .quad -9223372036854775808    ## double -0
39; CHECK-NEXT:   .quad -9223372036854775808    ## double -0
40; CHECK:        [[ONE3:L.+]]:
41; CHECK-NEXT:   .quad 4607182418800017408     ## double 1
42
43define double @mag_pos1_double(double %x) nounwind {
44; CHECK-LABEL: mag_pos1_double:
45; CHECK:       ## %bb.0:
46; CHECK-NEXT:    andps [[SIGNMASK3]](%rip), %xmm0
47; CHECK-NEXT:    movsd [[ONE3]](%rip), %xmm1
48; CHECK-NEXT:    movlhps {{.*#+}} xmm1 = xmm1[0,0]
49; CHECK-NEXT:    orps %xmm1, %xmm0
50; CHECK-NEXT:    retq
51;
52  %y = call double @copysign(double 1.0, double %x)
53  ret double %y
54}
55
56; CHECK:        [[SIGNMASK4:L.+]]:
57; CHECK-NEXT:   .quad -9223372036854775808    ## double -0
58; CHECK-NEXT:   .quad -9223372036854775808    ## double -0
59; CHECK:        [[ONE4:L.+]]:
60; CHECK-NEXT:   .quad 4607182418800017408     ## double 1
61; CHECK-NEXT:   .quad 4607182418800017408     ## double 1
62
63define double @mag_neg1_double(double %x) nounwind {
64; CHECK-LABEL: mag_neg1_double:
65; CHECK:       ## %bb.0:
66; CHECK-NEXT:    andps [[SIGNMASK4]](%rip), %xmm0
67; CHECK-NEXT:    orps [[ONE4]](%rip), %xmm0
68; CHECK-NEXT:    retq
69;
70  %y = call double @copysign(double -1.0, double %x)
71  ret double %y
72}
73
74; CHECK:       [[SIGNMASK5:L.+]]:
75; CHECK-NEXT:  .long 2147483648              ## float -0
76; CHECK-NEXT:  .long 2147483648              ## float -0
77
78define float @mag_pos0_float(float %x) nounwind {
79; CHECK-LABEL: mag_pos0_float:
80; CHECK:       ## %bb.0:
81; CHECK-NEXT:    andps [[SIGNMASK5]](%rip), %xmm0
82; CHECK-NEXT:    retq
83;
84  %y = call float @copysignf(float 0.0, float %x)
85  ret float %y
86}
87
88; CHECK:       [[SIGNMASK6:L.+]]:
89; CHECK-NEXT:  .long 2147483648              ## float -0
90
91define float @mag_neg0_float(float %x) nounwind {
92; CHECK-LABEL: mag_neg0_float:
93; CHECK:       ## %bb.0:
94; CHECK-NEXT:    movss [[SIGNMASK6]](%rip), %xmm1
95; CHECK-NEXT:    shufps {{.*#+}} xmm1 = xmm1[0,0,0,0]
96; CHECK-NEXT:    andps %xmm1, %xmm0
97; CHECK-NEXT:    retq
98;
99  %y = call float @copysignf(float -0.0, float %x)
100  ret float %y
101}
102
103; CHECK:       [[SIGNMASK7:L.+]]:
104; CHECK-NEXT:  .long 2147483648              ## float -0
105; CHECK-NEXT:  .long 2147483648              ## float -0
106; CHECK:        [[ONE7:L.+]]:
107; CHECK-NEXT:  .long 1065353216              ## float 1
108
109define float @mag_pos1_float(float %x) nounwind {
110; CHECK-LABEL: mag_pos1_float:
111; CHECK:       ## %bb.0:
112; CHECK-NEXT:    andps [[SIGNMASK7]](%rip), %xmm0
113; CHECK-NEXT:    movss [[ONE7]](%rip), %xmm1
114; CHECK-NEXT:    shufps {{.*#+}} xmm1 = xmm1[0,0,0,0]
115; CHECK-NEXT:    orps %xmm1, %xmm0
116; CHECK-NEXT:    retq
117;
118  %y = call float @copysignf(float 1.0, float %x)
119  ret float %y
120}
121
122; CHECK:       [[SIGNMASK8:L.+]]:
123; CHECK-NEXT:  .long 2147483648              ## float -0
124; CHECK-NEXT:  .long 2147483648              ## float -0
125; CHECK:        [[ONE8:L.+]]:
126; CHECK-NEXT:  .long 1065353216              ## float 1
127; CHECK-NEXT:  .long 1065353216              ## float 1
128; CHECK-NEXT:  .long 1065353216              ## float 1
129; CHECK-NEXT:  .long 1065353216              ## float 1
130
131define float @mag_neg1_float(float %x) nounwind {
132; CHECK-LABEL: mag_neg1_float:
133; CHECK:       ## %bb.0:
134; CHECK-NEXT:    andps [[SIGNMASK8]](%rip), %xmm0
135; CHECK-NEXT:    orps [[ONE8]](%rip), %xmm0
136; CHECK-NEXT:    retq
137;
138  %y = call float @copysignf(float -1.0, float %x)
139  ret float %y
140}
141
142declare double @copysign(double, double) nounwind readnone
143declare float @copysignf(float, float) nounwind readnone
144
145