aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/X86/avx-cmp.ll
blob: a050d6abe56f97d76632516ca84fa2ea03498b8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx -mattr=+avx | FileCheck %s

; CHECK: vcmpltps %ymm
; CHECK-NOT: vucomiss
define <8 x i32> @cmp00(<8 x float> %a, <8 x float> %b) nounwind readnone {
  %bincmp = fcmp olt <8 x float> %a, %b
  %s = sext <8 x i1> %bincmp to <8 x i32>
  ret <8 x i32> %s
}

; CHECK: vcmpltpd %ymm
; CHECK-NOT: vucomisd
define <4 x i64> @cmp01(<4 x double> %a, <4 x double> %b) nounwind readnone {
  %bincmp = fcmp olt <4 x double> %a, %b
  %s = sext <4 x i1> %bincmp to <4 x i64>
  ret <4 x i64> %s
}

declare void @scale() nounwind uwtable

; CHECK: vucomisd
define void @render() nounwind uwtable {
entry:
  br i1 undef, label %for.cond5, label %for.end52

for.cond5:
  %or.cond = and i1 undef, false
  br i1 %or.cond, label %for.body33, label %for.cond5

for.cond30:
  br i1 false, label %for.body33, label %for.cond5

for.body33:
  %tobool = fcmp une double undef, 0.000000e+00
  br i1 %tobool, label %if.then, label %for.cond30

if.then:
  call void @scale()
  br label %for.cond30

for.end52:
  ret void
}

; CHECK: vextractf128  $1
; CHECK: vextractf128  $1
; CHECK-NEXT: vpcmpgtd  %xmm
; CHECK-NEXT: vpcmpgtd  %xmm
; CHECK-NEXT: vinsertf128 $1
define <8 x i32> @int256-cmp(<8 x i32> %i, <8 x i32> %j) nounwind readnone {
  %bincmp = icmp slt <8 x i32> %i, %j
  %x = sext <8 x i1> %bincmp to <8 x i32>
  ret <8 x i32> %x
}

; CHECK: vextractf128  $1
; CHECK: vextractf128  $1
; CHECK-NEXT: vpcmpgtq  %xmm
; CHECK-NEXT: vpcmpgtq  %xmm
; CHECK-NEXT: vinsertf128 $1
define <4 x i64> @v4i64-cmp(<4 x i64> %i, <4 x i64> %j) nounwind readnone {
  %bincmp = icmp slt <4 x i64> %i, %j
  %x = sext <4 x i1> %bincmp to <4 x i64>
  ret <4 x i64> %x
}

; CHECK: vextractf128  $1
; CHECK: vextractf128  $1
; CHECK-NEXT: vpcmpgtw  %xmm
; CHECK-NEXT: vpcmpgtw  %xmm
; CHECK-NEXT: vinsertf128 $1
define <16 x i16> @v16i16-cmp(<16 x i16> %i, <16 x i16> %j) nounwind readnone {
  %bincmp = icmp slt <16 x i16> %i, %j
  %x = sext <16 x i1> %bincmp to <16 x i16>
  ret <16 x i16> %x
}

; CHECK: vextractf128  $1
; CHECK: vextractf128  $1
; CHECK-NEXT: vpcmpgtb  %xmm
; CHECK-NEXT: vpcmpgtb  %xmm
; CHECK-NEXT: vinsertf128 $1
define <32 x i8> @v32i8-cmp(<32 x i8> %i, <32 x i8> %j) nounwind readnone {
  %bincmp = icmp slt <32 x i8> %i, %j
  %x = sext <32 x i1> %bincmp to <32 x i8>
  ret <32 x i8> %x
}

; CHECK: vextractf128  $1
; CHECK: vextractf128  $1
; CHECK-NEXT: vpcmpeqd  %xmm
; CHECK-NEXT: vpcmpeqd  %xmm
; CHECK-NEXT: vinsertf128 $1
define <8 x i32> @int256-cmpeq(<8 x i32> %i, <8 x i32> %j) nounwind readnone {
  %bincmp = icmp eq <8 x i32> %i, %j
  %x = sext <8 x i1> %bincmp to <8 x i32>
  ret <8 x i32> %x
}

; CHECK: vextractf128  $1
; CHECK: vextractf128  $1
; CHECK-NEXT: vpcmpeqq  %xmm
; CHECK-NEXT: vpcmpeqq  %xmm
; CHECK-NEXT: vinsertf128 $1
define <4 x i64> @v4i64-cmpeq(<4 x i64> %i, <4 x i64> %j) nounwind readnone {
  %bincmp = icmp eq <4 x i64> %i, %j
  %x = sext <4 x i1> %bincmp to <4 x i64>
  ret <4 x i64> %x
}

; CHECK: vextractf128  $1
; CHECK: vextractf128  $1
; CHECK-NEXT: vpcmpeqw  %xmm
; CHECK-NEXT: vpcmpeqw  %xmm
; CHECK-NEXT: vinsertf128 $1
define <16 x i16> @v16i16-cmpeq(<16 x i16> %i, <16 x i16> %j) nounwind readnone {
  %bincmp = icmp eq <16 x i16> %i, %j
  %x = sext <16 x i1> %bincmp to <16 x i16>
  ret <16 x i16> %x
}

; CHECK: vextractf128  $1
; CHECK: vextractf128  $1
; CHECK-NEXT: vpcmpeqb  %xmm
; CHECK-NEXT: vpcmpeqb  %xmm
; CHECK-NEXT: vinsertf128 $1
define <32 x i8> @v32i8-cmpeq(<32 x i8> %i, <32 x i8> %j) nounwind readnone {
  %bincmp = icmp eq <32 x i8> %i, %j
  %x = sext <32 x i1> %bincmp to <32 x i8>
  ret <32 x i8> %x
}

;; Scalar comparison

; CHECK: scalarcmpA
; CHECK: vcmpeqsd
define i32 @scalarcmpA() uwtable ssp {
  %cmp29 = fcmp oeq double undef, 0.000000e+00
  %res = zext i1 %cmp29 to i32
  ret i32 %res
}

; CHECK: scalarcmpB
; CHECK: vcmpeqss
define i32 @scalarcmpB() uwtable ssp {
  %cmp29 = fcmp oeq float undef, 0.000000e+00
  %res = zext i1 %cmp29 to i32
  ret i32 %res
}