[PowerPC] Recommit r314244 with refactoring and off by default
[llvm-core.git] / test / CodeGen / X86 / avx512-cmp.ll
blobe75907a864a3e6da91a7869c5c4a51f3d72fec52
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx512f | FileCheck %s --check-prefix=ALL --check-prefix=KNL
3 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx512f,+avx512bw,+avx512vl,+avx512dq | FileCheck %s --check-prefix=ALL --check-prefix=SKX
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 ; ALL-NEXT:    ## -- End function
18   %tobool = fcmp une double %a, %b
19   br i1 %tobool, label %l1, label %l2
21 l1:
22   %c = fsub double %a, %b
23   ret double %c
24 l2:
25   %c1 = fadd double %a, %b
26   ret double %c1
29 define float @test2(float %a, float %b) nounwind {
30 ; ALL-LABEL: test2:
31 ; ALL:       ## BB#0:
32 ; ALL-NEXT:    vucomiss %xmm0, %xmm1
33 ; ALL-NEXT:    jbe LBB1_2
34 ; ALL-NEXT:  ## BB#1: ## %l1
35 ; ALL-NEXT:    vsubss %xmm1, %xmm0, %xmm0
36 ; ALL-NEXT:    retq
37 ; ALL-NEXT:  LBB1_2: ## %l2
38 ; ALL-NEXT:    vaddss %xmm1, %xmm0, %xmm0
39 ; ALL-NEXT:    retq
40 ; ALL-NEXT:    ## -- End function
41   %tobool = fcmp olt float %a, %b
42   br i1 %tobool, label %l1, label %l2
44 l1:
45   %c = fsub float %a, %b
46   ret float %c
47 l2:
48   %c1 = fadd float %a, %b
49   ret float %c1
52 define i32 @test3(float %a, float %b) {
53 ; KNL-LABEL: test3:
54 ; KNL:       ## BB#0:
55 ; KNL-NEXT:    vcmpeqss %xmm1, %xmm0, %k0
56 ; KNL-NEXT:    kmovw %k0, %eax
57 ; KNL-NEXT:    movzbl %al, %eax
58 ; KNL-NEXT:    retq
60 ; SKX-LABEL: test3:
61 ; SKX:       ## BB#0:
62 ; SKX-NEXT:    vcmpeqss %xmm1, %xmm0, %k0
63 ; SKX-NEXT:    kmovd %k0, %eax
64 ; SKX-NEXT:    movzbl %al, %eax
65 ; SKX-NEXT:    retq
67   %cmp10.i = fcmp oeq float %a, %b
68   %conv11.i = zext i1 %cmp10.i to i32
69   ret i32 %conv11.i
72 define float @test5(float %p) #0 {
73 ; ALL-LABEL: test5:
74 ; ALL:       ## BB#0: ## %entry
75 ; ALL-NEXT:    vxorps %xmm1, %xmm1, %xmm1
76 ; ALL-NEXT:    vucomiss %xmm1, %xmm0
77 ; ALL-NEXT:    jne LBB3_1
78 ; ALL-NEXT:    jp LBB3_1
79 ; ALL-NEXT:  ## BB#2: ## %return
80 ; ALL-NEXT:    retq
81 ; ALL-NEXT:  LBB3_1: ## %if.end
82 ; ALL-NEXT:    seta %al
83 ; ALL-NEXT:    movzbl %al, %eax
84 ; ALL-NEXT:    leaq {{.*}}(%rip), %rcx
85 ; ALL-NEXT:    vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
86 ; ALL-NEXT:    retq
87 entry:
88   %cmp = fcmp oeq float %p, 0.000000e+00
89   br i1 %cmp, label %return, label %if.end
91 if.end:                                           ; preds = %entry
92   %cmp1 = fcmp ogt float %p, 0.000000e+00
93   %cond = select i1 %cmp1, float 1.000000e+00, float -1.000000e+00
94   br label %return
96 return:                                           ; preds = %if.end, %entry
97   %retval.0 = phi float [ %cond, %if.end ], [ %p, %entry ]
98   ret float %retval.0
101 define i32 @test6(i32 %a, i32 %b) {
102 ; ALL-LABEL: test6:
103 ; ALL:       ## BB#0:
104 ; ALL-NEXT:    xorl %eax, %eax
105 ; ALL-NEXT:    cmpl %esi, %edi
106 ; ALL-NEXT:    sete %al
107 ; ALL-NEXT:    retq
108   %cmp = icmp eq i32 %a, %b
109   %res = zext i1 %cmp to i32
110   ret i32 %res
113 define i32 @test7(double %x, double %y) #2 {
114 ; ALL-LABEL: test7:
115 ; ALL:       ## BB#0: ## %entry
116 ; ALL-NEXT:    xorl %eax, %eax
117 ; ALL-NEXT:    vucomisd %xmm1, %xmm0
118 ; ALL-NEXT:    setne %al
119 ; ALL-NEXT:    retq
120 entry:
121   %0 = fcmp one double %x, %y
122   %or = zext i1 %0 to i32
123   ret i32 %or
126 define i32 @test8(i32 %a1, i32 %a2, i32 %a3) {
127 ; ALL-LABEL: test8:
128 ; ALL:       ## BB#0:
129 ; ALL-NEXT:    notl %edi
130 ; ALL-NEXT:    xorl $-2147483648, %esi ## imm = 0x80000000
131 ; ALL-NEXT:    testl %edx, %edx
132 ; ALL-NEXT:    movl $1, %eax
133 ; ALL-NEXT:    cmovel %eax, %edx
134 ; ALL-NEXT:    orl %edi, %esi
135 ; ALL-NEXT:    cmovnel %edx, %eax
136 ; ALL-NEXT:    retq
137   %tmp1 = icmp eq i32 %a1, -1
138   %tmp2 = icmp eq i32 %a2, -2147483648
139   %tmp3 = and i1 %tmp1, %tmp2
140   %tmp4 = icmp eq i32 %a3, 0
141   %tmp5 = or i1 %tmp3, %tmp4
142   %res = select i1 %tmp5, i32 1, i32 %a3
143   ret i32 %res
146 define i32 @test9(i64 %a) {
147 ; ALL-LABEL: test9:
148 ; ALL:       ## BB#0:
149 ; ALL-NEXT:    testb $1, %dil
150 ; ALL-NEXT:    jne LBB7_2
151 ; ALL-NEXT:  ## BB#1: ## %A
152 ; ALL-NEXT:    movl $6, %eax
153 ; ALL-NEXT:    retq
154 ; ALL-NEXT:  LBB7_2: ## %B
155 ; ALL-NEXT:    movl $7, %eax
156 ; ALL-NEXT:    retq
157  %b = and i64 %a, 1
158  %cmp10.i = icmp eq i64 %b, 0
159  br i1 %cmp10.i, label %A, label %B
161  ret i32 6
163  ret i32 7
166 define i32 @test10(i64 %b, i64 %c, i1 %d) {
167 ; ALL-LABEL: test10:
168 ; ALL:       ## BB#0:
169 ; ALL-NEXT:    movl %edx, %eax
170 ; ALL-NEXT:    andb $1, %al
171 ; ALL-NEXT:    cmpq %rsi, %rdi
172 ; ALL-NEXT:    sete %cl
173 ; ALL-NEXT:    orb %dl, %cl
174 ; ALL-NEXT:    andb $1, %cl
175 ; ALL-NEXT:    cmpb %cl, %al
176 ; ALL-NEXT:    je LBB8_1
177 ; ALL-NEXT:  ## BB#2: ## %if.end.i
178 ; ALL-NEXT:    movl $6, %eax
179 ; ALL-NEXT:    retq
180 ; ALL-NEXT:  LBB8_1: ## %if.then.i
181 ; ALL-NEXT:    movl $5, %eax
182 ; ALL-NEXT:    retq
184   %cmp8.i = icmp eq i64 %b, %c
185   %or1 = or i1 %d, %cmp8.i
186   %xor1 = xor i1 %d, %or1
187   br i1 %xor1, label %if.end.i, label %if.then.i
189 if.then.i:
190  ret i32 5
192 if.end.i:
193   ret i32 6