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
8 define i32 @t1(i32 %x) nounwind readnone ssp {
11 ; X32-NEXT: cmpl $1, {{[0-9]+}}(%esp)
12 ; X32-NEXT: sbbl %eax, %eax
17 ; X64-NEXT: cmpl $1, %edi
18 ; X64-NEXT: sbbl %eax, %eax
20 %t0 = icmp eq i32 %x, 0
21 %if = select i1 %t0, i32 -1, i32 0
25 define i32 @t2(i32 %x) nounwind readnone ssp {
28 ; X32-NEXT: cmpl $1, {{[0-9]+}}(%esp)
29 ; X32-NEXT: sbbl %eax, %eax
34 ; X64-NEXT: cmpl $1, %edi
35 ; X64-NEXT: sbbl %eax, %eax
37 %t0 = icmp eq i32 %x, 0
38 %if = sext i1 %t0 to i32
42 define i32 @t3(i32 %x, i64 %y) nounwind readonly {
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
54 ; X64: # %bb.0: # %entry
55 ; X64-NEXT: xorl %eax, %eax
56 ; X64-NEXT: testl %edi, %edi
59 ; X64-NEXT: cmpq %rax, %rsi
60 ; X64-NEXT: xorl %eax, %eax
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
74 %xor27 = xor i32 undef, %cond
78 define i32 @t4(i64 %x) nounwind readnone ssp {
81 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
82 ; X32-NEXT: xorl %eax, %eax
83 ; X32-NEXT: orl {{[0-9]+}}(%esp), %ecx
90 ; X64-NEXT: cmpq $1, %rdi
91 ; X64-NEXT: sbbl %eax, %eax
93 %t0 = icmp eq i64 %x, 0
94 %t1 = sext i1 %t0 to i32
98 define i64 @t5(i32 %x) nounwind readnone ssp {
101 ; X32-NEXT: cmpl $1, {{[0-9]+}}(%esp)
102 ; X32-NEXT: sbbl %eax, %eax
103 ; X32-NEXT: movl %eax, %edx
108 ; X64-NEXT: cmpl $1, %edi
109 ; X64-NEXT: sbbq %rax, %rax
111 %t0 = icmp eq i32 %x, 0
112 %t1 = sext i1 %t0 to i64
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:
121 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
122 ; X32-NEXT: andl $1, %eax
123 ; X32-NEXT: decl %eax
126 ; X64-LABEL: select_0_or_1s:
128 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
129 ; X64-NEXT: andl $1, %edi
130 ; X64-NEXT: leal -1(%rdi), %eax
132 %not = xor i1 %cond, 1
133 %sext = sext i1 %not to i32
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:
142 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
143 ; X32-NEXT: decl %eax
146 ; X64-LABEL: select_0_or_1s_zeroext:
148 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
149 ; X64-NEXT: leal -1(%rdi), %eax
151 %not = xor i1 %cond, 1
152 %sext = sext i1 %not to i32
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:
161 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
162 ; X32-NEXT: andl $1, %eax
163 ; X32-NEXT: decl %eax
166 ; X64-LABEL: select_0_or_1s_signext:
168 ; X64-NEXT: movl %edi, %eax
169 ; X64-NEXT: notl %eax
171 %not = xor i1 %cond, 1
172 %sext = sext i1 %not to i32
176 define i32 @zext_decrement_sext(i8 %x) {
177 ; X32-LABEL: zext_decrement_sext:
179 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
180 ; X32-NEXT: decl %eax
183 ; X64-LABEL: zext_decrement_sext:
185 ; X64-NEXT: movzbl %dil, %eax
186 ; X64-NEXT: decl %eax
188 %z = zext i8 %x to i16
189 %dec = add i16 %z, -1
190 %r = sext i16 %dec to i32