[Codegen] Adjust saturation test. NFC.
[llvm-core.git] / test / CodeGen / X86 / sext-i1.ll
blob6d548cfcdcbd30bc909a1af1140aadf629fafaa9
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i386-unknown-unknown -disable-cgp-branch-opts    | FileCheck %s --check-prefix=CHECK --check-prefix=X32
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -disable-cgp-branch-opts  | FileCheck %s --check-prefix=CHECK --check-prefix=X64
5 ; rdar://7573216
6 ; PR6146
8 define i32 @t1(i32 %x) nounwind readnone ssp {
9 ; X32-LABEL: t1:
10 ; X32:       # %bb.0:
11 ; X32-NEXT:    cmpl $1, {{[0-9]+}}(%esp)
12 ; X32-NEXT:    sbbl %eax, %eax
13 ; X32-NEXT:    retl
15 ; X64-LABEL: t1:
16 ; X64:       # %bb.0:
17 ; X64-NEXT:    cmpl $1, %edi
18 ; X64-NEXT:    sbbl %eax, %eax
19 ; X64-NEXT:    retq
20   %t0 = icmp eq i32 %x, 0
21   %if = select i1 %t0, i32 -1, i32 0
22   ret i32 %if
25 define i32 @t2(i32 %x) nounwind readnone ssp {
26 ; X32-LABEL: t2:
27 ; X32:       # %bb.0:
28 ; X32-NEXT:    cmpl $1, {{[0-9]+}}(%esp)
29 ; X32-NEXT:    sbbl %eax, %eax
30 ; X32-NEXT:    retl
32 ; X64-LABEL: t2:
33 ; X64:       # %bb.0:
34 ; X64-NEXT:    cmpl $1, %edi
35 ; X64-NEXT:    sbbl %eax, %eax
36 ; X64-NEXT:    retq
37   %t0 = icmp eq i32 %x, 0
38   %if = sext i1 %t0 to i32
39   ret i32 %if
42 define i32 @t3(i32 %x, i64 %y) nounwind readonly {
43 ; X32-LABEL: t3:
44 ; X32:       # %bb.0: # %entry
45 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
46 ; X32-NEXT:    cmpl $1, {{[0-9]+}}(%esp)
47 ; X32-NEXT:    sbbl %ecx, %ecx
48 ; X32-NEXT:    cmpl %ecx, {{[0-9]+}}(%esp)
49 ; X32-NEXT:    sbbl %ecx, %eax
50 ; X32-NEXT:    xorl %eax, %eax
51 ; X32-NEXT:    retl
53 ; X64-LABEL: t3:
54 ; X64:       # %bb.0: # %entry
55 ; X64-NEXT:    xorl %eax, %eax
56 ; X64-NEXT:    testl %edi, %edi
57 ; X64-NEXT:    sete %al
58 ; X64-NEXT:    negq %rax
59 ; X64-NEXT:    cmpq %rax, %rsi
60 ; X64-NEXT:    xorl %eax, %eax
61 ; X64-NEXT:    retq
62 entry:
63   %not.tobool = icmp eq i32 %x, 0
64   %cond = sext i1 %not.tobool to i32
65   %conv = sext i1 %not.tobool to i64
66   %add13 = add i64 0, %conv
67   %cmp = icmp ult i64 %y, %add13
68   br i1 %cmp, label %if.then, label %if.end
70 if.then:
71   br label %if.end
73 if.end:
74   %xor27 = xor i32 undef, %cond
75   ret i32 0
78 define i32 @t4(i64 %x) nounwind readnone ssp {
79 ; X32-LABEL: t4:
80 ; X32:       # %bb.0:
81 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
82 ; X32-NEXT:    xorl %eax, %eax
83 ; X32-NEXT:    orl {{[0-9]+}}(%esp), %ecx
84 ; X32-NEXT:    sete %al
85 ; X32-NEXT:    negl %eax
86 ; X32-NEXT:    retl
88 ; X64-LABEL: t4:
89 ; X64:       # %bb.0:
90 ; X64-NEXT:    cmpq $1, %rdi
91 ; X64-NEXT:    sbbl %eax, %eax
92 ; X64-NEXT:    retq
93   %t0 = icmp eq i64 %x, 0
94   %t1 = sext i1 %t0 to i32
95   ret i32 %t1
98 define i64 @t5(i32 %x) nounwind readnone ssp {
99 ; X32-LABEL: t5:
100 ; X32:       # %bb.0:
101 ; X32-NEXT:    cmpl $1, {{[0-9]+}}(%esp)
102 ; X32-NEXT:    sbbl %eax, %eax
103 ; X32-NEXT:    movl %eax, %edx
104 ; X32-NEXT:    retl
106 ; X64-LABEL: t5:
107 ; X64:       # %bb.0:
108 ; X64-NEXT:    cmpl $1, %edi
109 ; X64-NEXT:    sbbq %rax, %rax
110 ; X64-NEXT:    retq
111   %t0 = icmp eq i32 %x, 0
112   %t1 = sext i1 %t0 to i64
113   ret i64 %t1
116 ; sext (xor Bool, -1) --> sub (zext Bool), 1
118 define i32 @select_0_or_1s(i1 %cond) {
119 ; X32-LABEL: select_0_or_1s:
120 ; X32:       # %bb.0:
121 ; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
122 ; X32-NEXT:    andl $1, %eax
123 ; X32-NEXT:    decl %eax
124 ; X32-NEXT:    retl
126 ; X64-LABEL: select_0_or_1s:
127 ; X64:       # %bb.0:
128 ; X64-NEXT:    # kill: def $edi killed $edi def $rdi
129 ; X64-NEXT:    andl $1, %edi
130 ; X64-NEXT:    leal -1(%rdi), %eax
131 ; X64-NEXT:    retq
132   %not = xor i1 %cond, 1
133   %sext = sext i1 %not to i32
134   ret i32 %sext
137 ; sext (xor Bool, -1) --> sub (zext Bool), 1
139 define i32 @select_0_or_1s_zeroext(i1 zeroext %cond) {
140 ; X32-LABEL: select_0_or_1s_zeroext:
141 ; X32:       # %bb.0:
142 ; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
143 ; X32-NEXT:    decl %eax
144 ; X32-NEXT:    retl
146 ; X64-LABEL: select_0_or_1s_zeroext:
147 ; X64:       # %bb.0:
148 ; X64-NEXT:    # kill: def $edi killed $edi def $rdi
149 ; X64-NEXT:    leal -1(%rdi), %eax
150 ; X64-NEXT:    retq
151   %not = xor i1 %cond, 1
152   %sext = sext i1 %not to i32
153   ret i32 %sext
156 ; sext (xor Bool, -1) --> sub (zext Bool), 1
158 define i32 @select_0_or_1s_signext(i1 signext %cond) {
159 ; X32-LABEL: select_0_or_1s_signext:
160 ; X32:       # %bb.0:
161 ; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
162 ; X32-NEXT:    andl $1, %eax
163 ; X32-NEXT:    decl %eax
164 ; X32-NEXT:    retl
166 ; X64-LABEL: select_0_or_1s_signext:
167 ; X64:       # %bb.0:
168 ; X64-NEXT:    movl %edi, %eax
169 ; X64-NEXT:    notl %eax
170 ; X64-NEXT:    retq
171   %not = xor i1 %cond, 1
172   %sext = sext i1 %not to i32
173   ret i32 %sext
176 define i32 @zext_decrement_sext(i8 %x) {
177 ; X32-LABEL: zext_decrement_sext:
178 ; X32:       # %bb.0:
179 ; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
180 ; X32-NEXT:    decl %eax
181 ; X32-NEXT:    retl
183 ; X64-LABEL: zext_decrement_sext:
184 ; X64:       # %bb.0:
185 ; X64-NEXT:    movzbl %dil, %eax
186 ; X64-NEXT:    decl %eax
187 ; X64-NEXT:    retq
188   %z = zext i8 %x to i16
189   %dec = add i16 %z, -1
190   %r = sext i16 %dec to i32
191   ret i32 %r