[X86] Don't pass a scale value of 0 to scatter/gather intrinsics. This causes the...
[oota-llvm.git] / test / CodeGen / X86 / avx512-cmp.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl --show-mc-encoding | FileCheck %s
2 ; RUN: llc < %s -mtriple=i386-apple-darwin -mcpu=knl | FileCheck %s --check-prefix AVX512-32
3
4 ; CHECK-LABEL: test1
5 ; CHECK: vucomisd {{.*}}encoding: [0x62
6 define double @test1(double %a, double %b) nounwind {
7   %tobool = fcmp une double %a, %b
8   br i1 %tobool, label %l1, label %l2
9
10 l1:
11   %c = fsub double %a, %b
12   ret double %c
13 l2:
14   %c1 = fadd double %a, %b
15   ret double %c1
16 }
17
18 ; CHECK-LABEL: test2
19 ; CHECK: vucomiss {{.*}}encoding: [0x62
20 define float @test2(float %a, float %b) nounwind {
21   %tobool = fcmp olt float %a, %b
22   br i1 %tobool, label %l1, label %l2
23
24 l1:
25   %c = fsub float %a, %b
26   ret float %c
27 l2:
28   %c1 = fadd float %a, %b
29   ret float %c1
30 }
31
32 ; FIXME: Can use vcmpeqss and extract from the mask here in AVX512.
33 ; CHECK-LABEL: test3
34 ; CHECK: vucomiss {{.*}}encoding: [0x62
35 define i32 @test3(float %a, float %b) {
36
37   %cmp10.i = fcmp oeq float %a, %b
38   %conv11.i = zext i1 %cmp10.i to i32
39   ret i32 %conv11.i
40 }
41
42 ; CHECK-LABEL: test5
43 ; CHECK: ret
44 define float @test5(float %p) #0 {
45 entry:
46   %cmp = fcmp oeq float %p, 0.000000e+00
47   br i1 %cmp, label %return, label %if.end
48
49 if.end:                                           ; preds = %entry
50   %cmp1 = fcmp ogt float %p, 0.000000e+00
51   %cond = select i1 %cmp1, float 1.000000e+00, float -1.000000e+00
52   br label %return
53
54 return:                                           ; preds = %if.end, %entry
55   %retval.0 = phi float [ %cond, %if.end ], [ %p, %entry ]
56   ret float %retval.0
57 }
58
59 ; CHECK-LABEL: test6
60 ; CHECK: cmpl
61 ; CHECK-NOT: kmov
62 ; CHECK: ret
63 define i32 @test6(i32 %a, i32 %b) {
64   %cmp = icmp eq i32 %a, %b
65   %res = zext i1 %cmp to i32
66   ret i32 %res
67 }
68
69 ; CHECK-LABEL: test7
70 ; CHECK: vucomisd
71 ; CHECK-NOT: kmov
72 ; CHECK: ret
73 define i32 @test7(double %x, double %y) #2 {
74 entry:
75   %0 = fcmp one double %x, %y
76   %or = zext i1 %0 to i32
77   ret i32 %or
78 }
79
80 define i32 @test8(i32 %a1, i32 %a2, i32 %a3) {
81   %tmp1 = icmp eq i32 %a1, -1
82   %tmp2 = icmp eq i32 %a2, -2147483648
83   %tmp3 = and i1 %tmp1, %tmp2
84   %tmp4 = icmp eq i32 %a3, 0
85   %tmp5 = or i1 %tmp3, %tmp4
86   %res = select i1 %tmp5, i32 1, i32 %a3
87   ret i32 %res
88 }
89
90 ; CHECK-LABEL: test9
91 ; CHECK: testb
92 ; CHECK-NOT: kmov
93 ; CHECK: ret
94 define i32 @test9(i64 %a) {
95  %b = and i64 %a, 1
96  %cmp10.i = icmp eq i64 %b, 0
97  br i1 %cmp10.i, label %A, label %B
98 A:
99  ret i32 6
100 B:
101  ret i32 7
102 }
103
104 ; AVX512-32-LABEL: test10
105 ; AVX512-32: movl    4(%esp), %ecx
106 ; AVX512-32: cmpl    $9, (%ecx)
107 ; AVX512-32: seta    %al
108 ; AVX512-32: cmpl    $0, 4(%ecx)
109 ; AVX512-32: setg    %cl
110 ; AVX512-32: je
111 ; AVX512-32: movb    %cl, %al
112 ; AVX512-32: testb   $1, %al
113
114 define void @test10(i64* %i.addr)  {
115
116   %x = load i64, i64* %i.addr, align 8
117   %cmp = icmp slt i64 %x, 10
118   br i1 %cmp, label %true, label %false
119
120 true:
121   ret void
122
123 false:
124   ret void
125 }
126