1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=X64
5 define i32 @from_cmpeq(i32 %xx, i32 %y) {
6 ; X86-LABEL: from_cmpeq:
8 ; X86-NEXT: xorl %eax, %eax
9 ; X86-NEXT: cmpl $9, {{[0-9]+}}(%esp)
11 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
14 ; X64-LABEL: from_cmpeq:
16 ; X64-NEXT: xorl %eax, %eax
17 ; X64-NEXT: cmpl $9, %edi
19 ; X64-NEXT: andl %esi, %eax
21 %x = icmp eq i32 %xx, 9
22 %masked = and i32 %y, 1
24 %r = select i1 %x, i32 %masked, i32 0
28 define i32 @from_cmpeq_fail_bad_andmask(i32 %xx, i32 %y) {
29 ; X86-LABEL: from_cmpeq_fail_bad_andmask:
31 ; X86-NEXT: cmpl $9, {{[0-9]+}}(%esp)
32 ; X86-NEXT: je .LBB1_1
34 ; X86-NEXT: xorl %eax, %eax
37 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
38 ; X86-NEXT: andl $3, %eax
41 ; X64-LABEL: from_cmpeq_fail_bad_andmask:
43 ; X64-NEXT: andl $3, %esi
44 ; X64-NEXT: xorl %eax, %eax
45 ; X64-NEXT: cmpl $9, %edi
46 ; X64-NEXT: cmovel %esi, %eax
48 %x = icmp eq i32 %xx, 9
49 %masked = and i32 %y, 3
50 %r = select i1 %x, i32 %masked, i32 0
54 define i32 @from_i1(i1 %x, i32 %y) {
57 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
58 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
59 ; X86-NEXT: andl $1, %eax
64 ; X64-NEXT: movl %edi, %eax
65 ; X64-NEXT: andl %esi, %eax
66 ; X64-NEXT: andl $1, %eax
68 %masked = and i32 %y, 1
69 %r = select i1 %x, i32 %masked, i32 0
73 define i32 @from_trunc_i8(i8 %xx, i32 %y) {
74 ; X86-LABEL: from_trunc_i8:
76 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
77 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
78 ; X86-NEXT: andl $1, %eax
81 ; X64-LABEL: from_trunc_i8:
83 ; X64-NEXT: movl %edi, %eax
84 ; X64-NEXT: andl %esi, %eax
85 ; X64-NEXT: andl $1, %eax
87 %masked = and i32 %y, 1
88 %x = trunc i8 %xx to i1
89 %r = select i1 %x, i32 %masked, i32 0
93 define i32 @from_trunc_i64(i64 %xx, i32 %y) {
94 ; X86-LABEL: from_trunc_i64:
96 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
97 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
98 ; X86-NEXT: andl $1, %eax
101 ; X64-LABEL: from_trunc_i64:
103 ; X64-NEXT: movq %rdi, %rax
104 ; X64-NEXT: andl %esi, %eax
105 ; X64-NEXT: andl $1, %eax
106 ; X64-NEXT: # kill: def $eax killed $eax killed $rax
108 %masked = and i32 %y, 1
109 %x = trunc i64 %xx to i1
110 %r = select i1 %x, i32 %masked, i32 0
114 define i32 @from_i1_fail_bad_select0(i1 %x, i32 %y) {
115 ; X86-LABEL: from_i1_fail_bad_select0:
117 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
118 ; X86-NEXT: jne .LBB5_1
120 ; X86-NEXT: movl $1, %eax
123 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
124 ; X86-NEXT: andl $1, %eax
127 ; X64-LABEL: from_i1_fail_bad_select0:
129 ; X64-NEXT: andl $1, %esi
130 ; X64-NEXT: testb $1, %dil
131 ; X64-NEXT: movl $1, %eax
132 ; X64-NEXT: cmovnel %esi, %eax
134 %masked = and i32 %y, 1
135 %r = select i1 %x, i32 %masked, i32 1
139 define i32 @from_i1_fail_bad_select1(i1 %x, i32 %y) {
140 ; X86-LABEL: from_i1_fail_bad_select1:
142 ; X86-NEXT: xorl %eax, %eax
143 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
144 ; X86-NEXT: jne .LBB6_2
146 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
147 ; X86-NEXT: andl $1, %eax
151 ; X64-LABEL: from_i1_fail_bad_select1:
153 ; X64-NEXT: andl $1, %esi
154 ; X64-NEXT: xorl %eax, %eax
155 ; X64-NEXT: testb $1, %dil
156 ; X64-NEXT: cmovel %esi, %eax
158 %masked = and i32 %y, 1
159 %r = select i1 %x, i32 0, i32 %masked