1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s
4 define i8 @isnonneg_i8(i8 %x) {
5 ; CHECK-LABEL: isnonneg_i8:
7 ; CHECK-NEXT: movl %edi, %eax
8 ; CHECK-NEXT: sarb $7, %al
9 ; CHECK-NEXT: orb $42, %al
10 ; CHECK-NEXT: # kill: def $al killed $al killed $eax
12 %cond = icmp sgt i8 %x, -1
13 %r = select i1 %cond, i8 42, i8 -1
17 define i16 @isnonneg_i16(i16 %x) {
18 ; CHECK-LABEL: isnonneg_i16:
20 ; CHECK-NEXT: movswl %di, %eax
21 ; CHECK-NEXT: sarl $15, %eax
22 ; CHECK-NEXT: orl $542, %eax # imm = 0x21E
23 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
25 %cond = icmp sgt i16 %x, -1
26 %r = select i1 %cond, i16 542, i16 -1
30 define i32 @isnonneg_i32(i32 %x) {
31 ; CHECK-LABEL: isnonneg_i32:
33 ; CHECK-NEXT: movl %edi, %eax
34 ; CHECK-NEXT: sarl $31, %eax
35 ; CHECK-NEXT: orl $-42, %eax
37 %cond = icmp sgt i32 %x, -1
38 %r = select i1 %cond, i32 -42, i32 -1
42 define i64 @isnonneg_i64(i64 %x) {
43 ; CHECK-LABEL: isnonneg_i64:
45 ; CHECK-NEXT: movq %rdi, %rax
46 ; CHECK-NEXT: sarq $63, %rax
47 ; CHECK-NEXT: orq $2342342, %rax # imm = 0x23BDC6
49 %cond = icmp sgt i64 %x, -1
50 %r = select i1 %cond, i64 2342342, i64 -1
54 define <16 x i8> @isnonneg_v16i8(<16 x i8> %x) {
55 ; CHECK-LABEL: isnonneg_v16i8:
57 ; CHECK-NEXT: pxor %xmm1, %xmm1
58 ; CHECK-NEXT: pcmpgtb %xmm0, %xmm1
59 ; CHECK-NEXT: por {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
60 ; CHECK-NEXT: movdqa %xmm1, %xmm0
62 %cond = icmp sgt <16 x i8> %x, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
63 %r = select <16 x i1> %cond, <16 x i8> <i8 12, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42>, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
67 define <8 x i16> @isnonneg_v8i16(<8 x i16> %x) {
68 ; CHECK-LABEL: isnonneg_v8i16:
70 ; CHECK-NEXT: psraw $15, %xmm0
71 ; CHECK-NEXT: por {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
73 %cond = icmp sgt <8 x i16> %x, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
74 %r = select <8 x i1> %cond, <8 x i16> <i16 1, i16 542, i16 542, i16 542, i16 542, i16 542, i16 542, i16 1>, <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
78 define <4 x i32> @isnonneg_v4i32(<4 x i32> %x) {
79 ; CHECK-LABEL: isnonneg_v4i32:
81 ; CHECK-NEXT: psrad $31, %xmm0
82 ; CHECK-NEXT: por {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
84 %cond = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
85 %r = select <4 x i1> %cond, <4 x i32> <i32 0, i32 42, i32 -42, i32 1>, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
89 define <2 x i64> @isnonneg_v2i64(<2 x i64> %x) {
90 ; CHECK-LABEL: isnonneg_v2i64:
92 ; CHECK-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
93 ; CHECK-NEXT: psrad $31, %xmm0
94 ; CHECK-NEXT: por {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
96 %cond = icmp sgt <2 x i64> %x, <i64 -1, i64 -1>
97 %r = select <2 x i1> %cond, <2 x i64> <i64 2342342, i64 12>, <2 x i64> <i64 -1, i64 -1>
101 define i8 @isneg_i8(i8 %x) {
102 ; CHECK-LABEL: isneg_i8:
104 ; CHECK-NEXT: movl %edi, %eax
105 ; CHECK-NEXT: sarb $7, %al
106 ; CHECK-NEXT: andb $42, %al
107 ; CHECK-NEXT: # kill: def $al killed $al killed $eax
109 %cond = icmp slt i8 %x, 0
110 %r = select i1 %cond, i8 42, i8 0
114 define i16 @isneg_i16(i16 %x) {
115 ; CHECK-LABEL: isneg_i16:
117 ; CHECK-NEXT: movswl %di, %eax
118 ; CHECK-NEXT: shrl $15, %eax
119 ; CHECK-NEXT: andl $542, %eax # imm = 0x21E
120 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
122 %cond = icmp slt i16 %x, 0
123 %r = select i1 %cond, i16 542, i16 0
127 define i32 @isneg_i32(i32 %x) {
128 ; CHECK-LABEL: isneg_i32:
130 ; CHECK-NEXT: movl %edi, %eax
131 ; CHECK-NEXT: sarl $31, %eax
132 ; CHECK-NEXT: andl $-42, %eax
134 %cond = icmp slt i32 %x, 0
135 %r = select i1 %cond, i32 -42, i32 0
139 define i64 @isneg_i64(i64 %x) {
140 ; CHECK-LABEL: isneg_i64:
142 ; CHECK-NEXT: movq %rdi, %rax
143 ; CHECK-NEXT: sarq $63, %rax
144 ; CHECK-NEXT: andl $2342342, %eax # imm = 0x23BDC6
146 %cond = icmp slt i64 %x, 0
147 %r = select i1 %cond, i64 2342342, i64 0
151 define <16 x i8> @isneg_v16i8(<16 x i8> %x) {
152 ; CHECK-LABEL: isneg_v16i8:
154 ; CHECK-NEXT: pxor %xmm1, %xmm1
155 ; CHECK-NEXT: pcmpgtb %xmm0, %xmm1
156 ; CHECK-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
157 ; CHECK-NEXT: movdqa %xmm1, %xmm0
159 %cond = icmp slt <16 x i8> %x, zeroinitializer
160 %r = select <16 x i1> %cond, <16 x i8> <i8 12, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42>, <16 x i8> zeroinitializer
164 define <8 x i16> @isneg_v8i16(<8 x i16> %x) {
165 ; CHECK-LABEL: isneg_v8i16:
167 ; CHECK-NEXT: psraw $15, %xmm0
168 ; CHECK-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
170 %cond = icmp slt <8 x i16> %x, zeroinitializer
171 %r = select <8 x i1> %cond, <8 x i16> <i16 1, i16 542, i16 542, i16 542, i16 542, i16 542, i16 542, i16 1>, <8 x i16> zeroinitializer
175 define <4 x i32> @isneg_v4i32(<4 x i32> %x) {
176 ; CHECK-LABEL: isneg_v4i32:
178 ; CHECK-NEXT: psrad $31, %xmm0
179 ; CHECK-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
181 %cond = icmp slt <4 x i32> %x, zeroinitializer
182 %r = select <4 x i1> %cond, <4 x i32> <i32 0, i32 42, i32 -42, i32 1>, <4 x i32> zeroinitializer
186 define <2 x i64> @isneg_v2i64(<2 x i64> %x) {
187 ; CHECK-LABEL: isneg_v2i64:
189 ; CHECK-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
190 ; CHECK-NEXT: psrad $31, %xmm0
191 ; CHECK-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
193 %cond = icmp slt <2 x i64> %x, zeroinitializer
194 %r = select <2 x i1> %cond, <2 x i64> <i64 2342342, i64 12>, <2 x i64> zeroinitializer