]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/X86/avx512-cmp.ll
Vendor import of llvm trunk r303571:
[FreeBSD/FreeBSD.git] / test / CodeGen / X86 / avx512-cmp.ll
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
5 define 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
20 l1:
21   %c = fsub double %a, %b
22   ret double %c
23 l2:
24   %c1 = fadd double %a, %b
25   ret double %c1
26 }
27
28 define 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
42 l1:
43   %c = fsub float %a, %b
44   ret float %c
45 l2:
46   %c1 = fadd float %a, %b
47   ret float %c1
48 }
49
50 define i32 @test3(float %a, float %b) {
51 ; KNL-LABEL: test3:
52 ; KNL:       ## BB#0:
53 ; KNL-NEXT:    vcmpeqss %xmm1, %xmm0, %k0
54 ; KNL-NEXT:    kmovw %k0, %eax
55 ; KNL-NEXT:    movzbl %al, %eax
56 ; KNL-NEXT:    retq
57 ;
58 ; SKX-LABEL: test3:
59 ; SKX:       ## BB#0:
60 ; SKX-NEXT:    vcmpeqss %xmm1, %xmm0, %k0
61 ; SKX-NEXT:    kmovd %k0, %eax
62 ; SKX-NEXT:    movzbl %al, %eax
63 ; SKX-NEXT:    retq
64
65   %cmp10.i = fcmp oeq float %a, %b
66   %conv11.i = zext i1 %cmp10.i to i32
67   ret i32 %conv11.i
68 }
69
70 define float @test5(float %p) #0 {
71 ; ALL-LABEL: test5:
72 ; ALL:       ## BB#0: ## %entry
73 ; ALL-NEXT:    vxorps %xmm1, %xmm1, %xmm1
74 ; ALL-NEXT:    vucomiss %xmm1, %xmm0
75 ; ALL-NEXT:    jne LBB3_1
76 ; ALL-NEXT:    jp LBB3_1
77 ; ALL-NEXT:  ## BB#2: ## %return
78 ; ALL-NEXT:    retq
79 ; ALL-NEXT:  LBB3_1: ## %if.end
80 ; ALL-NEXT:    seta %al
81 ; ALL-NEXT:    movzbl %al, %eax
82 ; ALL-NEXT:    leaq {{.*}}(%rip), %rcx
83 ; ALL-NEXT:    vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
84 ; ALL-NEXT:    retq
85 entry:
86   %cmp = fcmp oeq float %p, 0.000000e+00
87   br i1 %cmp, label %return, label %if.end
88
89 if.end:                                           ; preds = %entry
90   %cmp1 = fcmp ogt float %p, 0.000000e+00
91   %cond = select i1 %cmp1, float 1.000000e+00, float -1.000000e+00
92   br label %return
93
94 return:                                           ; preds = %if.end, %entry
95   %retval.0 = phi float [ %cond, %if.end ], [ %p, %entry ]
96   ret float %retval.0
97 }
98
99 define i32 @test6(i32 %a, i32 %b) {
100 ; ALL-LABEL: test6:
101 ; ALL:       ## BB#0:
102 ; ALL-NEXT:    xorl %eax, %eax
103 ; ALL-NEXT:    cmpl %esi, %edi
104 ; ALL-NEXT:    sete %al
105 ; ALL-NEXT:    retq
106   %cmp = icmp eq i32 %a, %b
107   %res = zext i1 %cmp to i32
108   ret i32 %res
109 }
110
111 define i32 @test7(double %x, double %y) #2 {
112 ; ALL-LABEL: test7:
113 ; ALL:       ## BB#0: ## %entry
114 ; ALL-NEXT:    xorl %eax, %eax
115 ; ALL-NEXT:    vucomisd %xmm1, %xmm0
116 ; ALL-NEXT:    setne %al
117 ; ALL-NEXT:    retq
118 entry:
119   %0 = fcmp one double %x, %y
120   %or = zext i1 %0 to i32
121   ret i32 %or
122 }
123
124 define i32 @test8(i32 %a1, i32 %a2, i32 %a3) {
125 ; ALL-LABEL: test8:
126 ; ALL:       ## BB#0:
127 ; ALL-NEXT:    notl %edi
128 ; ALL-NEXT:    xorl $-2147483648, %esi ## imm = 0x80000000
129 ; ALL-NEXT:    testl %edx, %edx
130 ; ALL-NEXT:    movl $1, %eax
131 ; ALL-NEXT:    cmovel %eax, %edx
132 ; ALL-NEXT:    orl %edi, %esi
133 ; ALL-NEXT:    cmovnel %edx, %eax
134 ; ALL-NEXT:    retq
135   %tmp1 = icmp eq i32 %a1, -1
136   %tmp2 = icmp eq i32 %a2, -2147483648
137   %tmp3 = and i1 %tmp1, %tmp2
138   %tmp4 = icmp eq i32 %a3, 0
139   %tmp5 = or i1 %tmp3, %tmp4
140   %res = select i1 %tmp5, i32 1, i32 %a3
141   ret i32 %res
142 }
143
144 define i32 @test9(i64 %a) {
145 ; ALL-LABEL: test9:
146 ; ALL:       ## BB#0:
147 ; ALL-NEXT:    testb $1, %dil
148 ; ALL-NEXT:    jne LBB7_2
149 ; ALL-NEXT:  ## BB#1: ## %A
150 ; ALL-NEXT:    movl $6, %eax
151 ; ALL-NEXT:    retq
152 ; ALL-NEXT:  LBB7_2: ## %B
153 ; ALL-NEXT:    movl $7, %eax
154 ; ALL-NEXT:    retq
155  %b = and i64 %a, 1
156  %cmp10.i = icmp eq i64 %b, 0
157  br i1 %cmp10.i, label %A, label %B
158 A:
159  ret i32 6
160 B:
161  ret i32 7
162 }
163
164 define i32 @test10(i64 %b, i64 %c, i1 %d) {
165 ; ALL-LABEL: test10:
166 ; ALL:       ## BB#0:
167 ; ALL-NEXT:    movl %edx, %eax
168 ; ALL-NEXT:    andb $1, %al
169 ; ALL-NEXT:    cmpq %rsi, %rdi
170 ; ALL-NEXT:    sete %cl
171 ; ALL-NEXT:    orb %dl, %cl
172 ; ALL-NEXT:    andb $1, %cl
173 ; ALL-NEXT:    cmpb %cl, %al
174 ; ALL-NEXT:    je LBB8_1
175 ; ALL-NEXT:  ## BB#2: ## %if.end.i
176 ; ALL-NEXT:    movl $6, %eax
177 ; ALL-NEXT:    retq
178 ; ALL-NEXT:  LBB8_1: ## %if.then.i
179 ; ALL-NEXT:    movl $5, %eax
180 ; ALL-NEXT:    retq
181
182   %cmp8.i = icmp eq i64 %b, %c
183   %or1 = or i1 %d, %cmp8.i
184   %xor1 = xor i1 %d, %or1
185   br i1 %xor1, label %if.end.i, label %if.then.i
186
187 if.then.i:
188  ret i32 5
189
190 if.end.i:
191   ret i32 6
192 }