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=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -disable-cgp-branch-opts | FileCheck %s --check-prefix=X64
8 define i32 @t1(i32 %x) nounwind readnone ssp {
11 ; X86-NEXT: xorl %eax, %eax
12 ; X86-NEXT: cmpl $1, {{[0-9]+}}(%esp)
13 ; X86-NEXT: sbbl %eax, %eax
18 ; X64-NEXT: xorl %eax, %eax
19 ; X64-NEXT: cmpl $1, %edi
20 ; X64-NEXT: sbbl %eax, %eax
22 %t0 = icmp eq i32 %x, 0
23 %if = select i1 %t0, i32 -1, i32 0
27 define i32 @t2(i32 %x) nounwind readnone ssp {
30 ; X86-NEXT: xorl %eax, %eax
31 ; X86-NEXT: cmpl $1, {{[0-9]+}}(%esp)
32 ; X86-NEXT: sbbl %eax, %eax
37 ; X64-NEXT: xorl %eax, %eax
38 ; X64-NEXT: cmpl $1, %edi
39 ; X64-NEXT: sbbl %eax, %eax
41 %t0 = icmp eq i32 %x, 0
42 %if = sext i1 %t0 to i32
46 define i32 @t3(i32 %x, i64 %y) nounwind readonly {
48 ; X86: # %bb.0: # %entry
49 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
50 ; X86-NEXT: xorl %ecx, %ecx
51 ; X86-NEXT: cmpl $1, {{[0-9]+}}(%esp)
52 ; X86-NEXT: sbbl %ecx, %ecx
53 ; X86-NEXT: cmpl %ecx, {{[0-9]+}}(%esp)
54 ; X86-NEXT: sbbl %ecx, %eax
55 ; X86-NEXT: xorl %eax, %eax
59 ; X64: # %bb.0: # %entry
60 ; X64-NEXT: xorl %eax, %eax
61 ; X64-NEXT: testl %edi, %edi
64 ; X64-NEXT: cmpq %rax, %rsi
65 ; X64-NEXT: xorl %eax, %eax
68 %not.tobool = icmp eq i32 %x, 0
69 %cond = sext i1 %not.tobool to i32
70 %conv = sext i1 %not.tobool to i64
71 %add13 = add i64 0, %conv
72 %cmp = icmp ult i64 %y, %add13
73 br i1 %cmp, label %if.then, label %if.end
79 %xor27 = xor i32 undef, %cond
83 define i32 @t4(i64 %x) nounwind readnone ssp {
86 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
87 ; X86-NEXT: xorl %eax, %eax
88 ; X86-NEXT: orl {{[0-9]+}}(%esp), %ecx
95 ; X64-NEXT: xorl %eax, %eax
96 ; X64-NEXT: cmpq $1, %rdi
97 ; X64-NEXT: sbbl %eax, %eax
99 %t0 = icmp eq i64 %x, 0
100 %t1 = sext i1 %t0 to i32
104 define i64 @t5(i32 %x) nounwind readnone ssp {
107 ; X86-NEXT: xorl %eax, %eax
108 ; X86-NEXT: cmpl $1, {{[0-9]+}}(%esp)
109 ; X86-NEXT: sbbl %eax, %eax
110 ; X86-NEXT: movl %eax, %edx
115 ; X64-NEXT: xorl %eax, %eax
116 ; X64-NEXT: cmpl $1, %edi
117 ; X64-NEXT: sbbq %rax, %rax
119 %t0 = icmp eq i32 %x, 0
120 %t1 = sext i1 %t0 to i64
124 ; sext (xor Bool, -1) --> sub (zext Bool), 1
126 define i32 @select_0_or_1s(i1 %cond) {
127 ; X86-LABEL: select_0_or_1s:
129 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
130 ; X86-NEXT: andl $1, %eax
131 ; X86-NEXT: decl %eax
134 ; X64-LABEL: select_0_or_1s:
136 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
137 ; X64-NEXT: andl $1, %edi
138 ; X64-NEXT: leal -1(%rdi), %eax
140 %not = xor i1 %cond, 1
141 %sext = sext i1 %not to i32
145 ; sext (xor Bool, -1) --> sub (zext Bool), 1
147 define i32 @select_0_or_1s_zeroext(i1 zeroext %cond) {
148 ; X86-LABEL: select_0_or_1s_zeroext:
150 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
151 ; X86-NEXT: decl %eax
154 ; X64-LABEL: select_0_or_1s_zeroext:
156 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
157 ; X64-NEXT: leal -1(%rdi), %eax
159 %not = xor i1 %cond, 1
160 %sext = sext i1 %not to i32
164 ; sext (xor Bool, -1) --> sub (zext Bool), 1
166 define i32 @select_0_or_1s_signext(i1 signext %cond) {
167 ; X86-LABEL: select_0_or_1s_signext:
169 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
170 ; X86-NEXT: andl $1, %eax
171 ; X86-NEXT: decl %eax
174 ; X64-LABEL: select_0_or_1s_signext:
176 ; X64-NEXT: movl %edi, %eax
177 ; X64-NEXT: notl %eax
179 %not = xor i1 %cond, 1
180 %sext = sext i1 %not to i32
184 define i32 @zext_decrement_sext(i8 %x) {
185 ; X86-LABEL: zext_decrement_sext:
187 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
188 ; X86-NEXT: decl %eax
191 ; X64-LABEL: zext_decrement_sext:
193 ; X64-NEXT: movzbl %dil, %eax
194 ; X64-NEXT: decl %eax
196 %z = zext i8 %x to i16
197 %dec = add i16 %z, -1
198 %r = sext i16 %dec to i32