• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl  | FileCheck %s --check-prefix=ALL --check-prefix=KNL
3; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=skx  | FileCheck %s --check-prefix=ALL --check-prefix=SKX
4
5define double @test1(double %a, double %b) nounwind {
6; ALL-LABEL: test1:
7; ALL:       ## BB#0:
8; ALL-NEXT:    vucomisd %xmm1, %xmm0
9; ALL-NEXT:    jne LBB0_1
10; ALL-NEXT:    jnp LBB0_2
11; ALL-NEXT:  LBB0_1: ## %l1
12; ALL-NEXT:    vsubsd %xmm1, %xmm0, %xmm0
13; ALL-NEXT:    retq
14; ALL-NEXT:  LBB0_2: ## %l2
15; ALL-NEXT:    vaddsd %xmm1, %xmm0, %xmm0
16; ALL-NEXT:    retq
17  %tobool = fcmp une double %a, %b
18  br i1 %tobool, label %l1, label %l2
19
20l1:
21  %c = fsub double %a, %b
22  ret double %c
23l2:
24  %c1 = fadd double %a, %b
25  ret double %c1
26}
27
28define float @test2(float %a, float %b) nounwind {
29; ALL-LABEL: test2:
30; ALL:       ## BB#0:
31; ALL-NEXT:    vucomiss %xmm0, %xmm1
32; ALL-NEXT:    jbe LBB1_2
33; ALL-NEXT:  ## BB#1: ## %l1
34; ALL-NEXT:    vsubss %xmm1, %xmm0, %xmm0
35; ALL-NEXT:    retq
36; ALL-NEXT:  LBB1_2: ## %l2
37; ALL-NEXT:    vaddss %xmm1, %xmm0, %xmm0
38; ALL-NEXT:    retq
39  %tobool = fcmp olt float %a, %b
40  br i1 %tobool, label %l1, label %l2
41
42l1:
43  %c = fsub float %a, %b
44  ret float %c
45l2:
46  %c1 = fadd float %a, %b
47  ret float %c1
48}
49
50; FIXME: Can use vcmpeqss and extract from the mask here in AVX512.
51define i32 @test3(float %a, float %b) {
52; ALL-LABEL: test3:
53; ALL:       ## BB#0:
54; ALL-NEXT:    vucomiss %xmm1, %xmm0
55; ALL-NEXT:    setnp %al
56; ALL-NEXT:    sete %cl
57; ALL-NEXT:    andb %al, %cl
58; ALL-NEXT:    movzbl %cl, %eax
59; ALL-NEXT:    retq
60
61  %cmp10.i = fcmp oeq float %a, %b
62  %conv11.i = zext i1 %cmp10.i to i32
63  ret i32 %conv11.i
64}
65
66define float @test5(float %p) #0 {
67; ALL-LABEL: test5:
68; ALL:       ## BB#0: ## %entry
69; ALL-NEXT:    vxorps %xmm1, %xmm1, %xmm1
70; ALL-NEXT:    vucomiss %xmm1, %xmm0
71; ALL-NEXT:    jne LBB3_1
72; ALL-NEXT:    jnp LBB3_2
73; ALL-NEXT:  LBB3_1: ## %if.end
74; ALL-NEXT:    seta %al
75; ALL-NEXT:    movzbl %al, %eax
76; ALL-NEXT:    leaq {{.*}}(%rip), %rcx
77; ALL-NEXT:    vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
78; ALL-NEXT:  LBB3_2: ## %return
79; ALL-NEXT:    retq
80entry:
81  %cmp = fcmp oeq float %p, 0.000000e+00
82  br i1 %cmp, label %return, label %if.end
83
84if.end:                                           ; preds = %entry
85  %cmp1 = fcmp ogt float %p, 0.000000e+00
86  %cond = select i1 %cmp1, float 1.000000e+00, float -1.000000e+00
87  br label %return
88
89return:                                           ; preds = %if.end, %entry
90  %retval.0 = phi float [ %cond, %if.end ], [ %p, %entry ]
91  ret float %retval.0
92}
93
94define i32 @test6(i32 %a, i32 %b) {
95; ALL-LABEL: test6:
96; ALL:       ## BB#0:
97; ALL-NEXT:    xorl %eax, %eax
98; ALL-NEXT:    cmpl %esi, %edi
99; ALL-NEXT:    sete %al
100; ALL-NEXT:    retq
101  %cmp = icmp eq i32 %a, %b
102  %res = zext i1 %cmp to i32
103  ret i32 %res
104}
105
106define i32 @test7(double %x, double %y) #2 {
107; ALL-LABEL: test7:
108; ALL:       ## BB#0: ## %entry
109; ALL-NEXT:    xorl %eax, %eax
110; ALL-NEXT:    vucomisd %xmm1, %xmm0
111; ALL-NEXT:    setne %al
112; ALL-NEXT:    retq
113entry:
114  %0 = fcmp one double %x, %y
115  %or = zext i1 %0 to i32
116  ret i32 %or
117}
118
119define i32 @test8(i32 %a1, i32 %a2, i32 %a3) {
120; ALL-LABEL: test8:
121; ALL:       ## BB#0:
122; ALL-NEXT:    testl %edx, %edx
123; ALL-NEXT:    movl $1, %eax
124; ALL-NEXT:    cmovel %eax, %edx
125; ALL-NEXT:    cmpl $-2147483648, %esi ## imm = 0x80000000
126; ALL-NEXT:    cmovnel %edx, %eax
127; ALL-NEXT:    cmpl $-1, %edi
128; ALL-NEXT:    cmovnel %edx, %eax
129; ALL-NEXT:    retq
130  %tmp1 = icmp eq i32 %a1, -1
131  %tmp2 = icmp eq i32 %a2, -2147483648
132  %tmp3 = and i1 %tmp1, %tmp2
133  %tmp4 = icmp eq i32 %a3, 0
134  %tmp5 = or i1 %tmp3, %tmp4
135  %res = select i1 %tmp5, i32 1, i32 %a3
136  ret i32 %res
137}
138
139define i32 @test9(i64 %a) {
140; ALL-LABEL: test9:
141; ALL:       ## BB#0:
142; ALL-NEXT:    testb $1, %dil
143; ALL-NEXT:    jne LBB7_2
144; ALL-NEXT:  ## BB#1: ## %A
145; ALL-NEXT:    movl $6, %eax
146; ALL-NEXT:    retq
147; ALL-NEXT:  LBB7_2: ## %B
148; ALL-NEXT:    movl $7, %eax
149; ALL-NEXT:    retq
150 %b = and i64 %a, 1
151 %cmp10.i = icmp eq i64 %b, 0
152 br i1 %cmp10.i, label %A, label %B
153A:
154 ret i32 6
155B:
156 ret i32 7
157}
158
159define i32 @test10(i64 %b, i64 %c, i1 %d) {
160; ALL-LABEL: test10:
161; ALL:       ## BB#0:
162; ALL-NEXT:    andl $1, %edx
163; ALL-NEXT:    kmovw %edx, %k0
164; ALL-NEXT:    cmpq %rsi, %rdi
165; ALL-NEXT:    sete %al
166; ALL-NEXT:    kmovw %eax, %k1
167; ALL-NEXT:    korw %k1, %k0, %k1
168; ALL-NEXT:    kxorw %k1, %k0, %k0
169; ALL-NEXT:    kmovw %k0, %eax
170; ALL-NEXT:    testb %al, %al
171; ALL-NEXT:    je LBB8_1
172; ALL-NEXT:  ## BB#2: ## %if.end.i
173; ALL-NEXT:    movl $6, %eax
174; ALL-NEXT:    retq
175; ALL-NEXT:  LBB8_1: ## %if.then.i
176; ALL-NEXT:    movl $5, %eax
177; ALL-NEXT:    retq
178
179  %cmp8.i = icmp eq i64 %b, %c
180  %or1 = or i1 %d, %cmp8.i
181  %xor1 = xor i1 %d, %or1
182  br i1 %xor1, label %if.end.i, label %if.then.i
183
184if.then.i:
185 ret i32 5
186
187if.end.i:
188  ret i32 6
189}
190