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() nounwind readonly {
44 ; X32: # %bb.0: # %entry
45 ; X32-NEXT: cmpl $1, %eax
46 ; X32-NEXT: sbbl %eax, %eax
47 ; X32-NEXT: cmpl %eax, %eax
48 ; X32-NEXT: sbbl %eax, %eax
49 ; X32-NEXT: xorl %eax, %eax
53 ; X64: # %bb.0: # %entry
54 ; X64-NEXT: xorl %eax, %eax
55 ; X64-NEXT: testl %eax, %eax
58 ; X64-NEXT: cmpq %rax, %rax
59 ; X64-NEXT: xorl %eax, %eax
62 %not.tobool = icmp eq i32 undef, 0
63 %cond = sext i1 %not.tobool to i32
64 %conv = sext i1 %not.tobool to i64
65 %add13 = add i64 0, %conv
66 %cmp = icmp ult i64 undef, %add13
67 br i1 %cmp, label %if.then, label %if.end
73 %xor27 = xor i32 undef, %cond
77 define i32 @t4(i64 %x) nounwind readnone ssp {
80 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
81 ; X32-NEXT: xorl %eax, %eax
82 ; X32-NEXT: orl {{[0-9]+}}(%esp), %ecx
89 ; X64-NEXT: cmpq $1, %rdi
90 ; X64-NEXT: sbbl %eax, %eax
92 %t0 = icmp eq i64 %x, 0
93 %t1 = sext i1 %t0 to i32
97 define i64 @t5(i32 %x) nounwind readnone ssp {
100 ; X32-NEXT: cmpl $1, {{[0-9]+}}(%esp)
101 ; X32-NEXT: sbbl %eax, %eax
102 ; X32-NEXT: movl %eax, %edx
107 ; X64-NEXT: cmpl $1, %edi
108 ; X64-NEXT: sbbq %rax, %rax
110 %t0 = icmp eq i32 %x, 0
111 %t1 = sext i1 %t0 to i64
115 ; sext (xor Bool, -1) --> sub (zext Bool), 1
117 define i32 @select_0_or_1s(i1 %cond) {
118 ; X32-LABEL: select_0_or_1s:
120 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
121 ; X32-NEXT: andl $1, %eax
122 ; X32-NEXT: decl %eax
125 ; X64-LABEL: select_0_or_1s:
127 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
128 ; X64-NEXT: andl $1, %edi
129 ; X64-NEXT: leal -1(%rdi), %eax
131 %not = xor i1 %cond, 1
132 %sext = sext i1 %not to i32
136 ; sext (xor Bool, -1) --> sub (zext Bool), 1
138 define i32 @select_0_or_1s_zeroext(i1 zeroext %cond) {
139 ; X32-LABEL: select_0_or_1s_zeroext:
141 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
142 ; X32-NEXT: decl %eax
145 ; X64-LABEL: select_0_or_1s_zeroext:
147 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
148 ; X64-NEXT: leal -1(%rdi), %eax
150 %not = xor i1 %cond, 1
151 %sext = sext i1 %not to i32
155 ; sext (xor Bool, -1) --> sub (zext Bool), 1
157 define i32 @select_0_or_1s_signext(i1 signext %cond) {
158 ; X32-LABEL: select_0_or_1s_signext:
160 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
161 ; X32-NEXT: andl $1, %eax
162 ; X32-NEXT: decl %eax
165 ; X64-LABEL: select_0_or_1s_signext:
167 ; X64-NEXT: movl %edi, %eax
168 ; X64-NEXT: notl %eax
170 %not = xor i1 %cond, 1
171 %sext = sext i1 %not to i32