1 ; RUN: llc < %s -march=x86 -mattr=+sse2 | FileCheck %s -check-prefix=X32
2 ; RUN: llc < %s -mtriple=x86_64-linux -mattr=+sse2 | FileCheck %s -check-prefix=X64
3 ; RUN: llc < %s -mtriple=x86_64-win32 -mattr=+sse2 | FileCheck %s -check-prefix=X64
5 ; Though it is undefined, we want xor undef,undef to produce zero.
6 define <4 x i32> @test1() nounwind {
7 %tmp = xor <4 x i32> undef, undef
11 ; X32: xorps %xmm0, %xmm0
15 ; Though it is undefined, we want xor undef,undef to produce zero.
16 define i32 @test2() nounwind{
17 %tmp = xor i32 undef, undef
20 ; X32: xorl %eax, %eax
24 define i32 @test3(i32 %a, i32 %b) nounwind {
26 %tmp1not = xor i32 %b, -2
27 %tmp3 = and i32 %tmp1not, %a
28 %tmp4 = lshr i32 %tmp3, 1
38 ; X32: movl 8(%esp), %eax
40 ; X32: andl 4(%esp), %eax
45 define i32 @test4(i32 %a, i32 %b) nounwind {
49 %b_addr.0 = phi i32 [ %b, %entry ], [ %tmp8, %bb ]
50 %a_addr.0 = phi i32 [ %a, %entry ], [ %tmp3, %bb ]
51 %tmp3 = xor i32 %a_addr.0, %b_addr.0
52 %tmp4not = xor i32 %tmp3, 2147483647
53 %tmp6 = and i32 %tmp4not, %b_addr.0
54 %tmp8 = shl i32 %tmp6, 1
55 %tmp10 = icmp eq i32 %tmp8, 0
56 br i1 %tmp10, label %bb12, label %bb
61 ; X64: notl [[REG:%[a-z]+]]
62 ; X64: andl {{.*}}[[REG]]
64 ; X32: notl [[REG:%[a-z]+]]
65 ; X32: andl {{.*}}[[REG]]
68 define i16 @test5(i16 %a, i16 %b) nounwind {
72 %b_addr.0 = phi i16 [ %b, %entry ], [ %tmp8, %bb ]
73 %a_addr.0 = phi i16 [ %a, %entry ], [ %tmp3, %bb ]
74 %tmp3 = xor i16 %a_addr.0, %b_addr.0
75 %tmp4not = xor i16 %tmp3, 32767
76 %tmp6 = and i16 %tmp4not, %b_addr.0
77 %tmp8 = shl i16 %tmp6, 1
78 %tmp10 = icmp eq i16 %tmp8, 0
79 br i1 %tmp10, label %bb12, label %bb
83 ; X64: notl [[REG:%[a-z]+]]
84 ; X64: andl {{.*}}[[REG]]
86 ; X32: notl [[REG:%[a-z]+]]
87 ; X32: andl {{.*}}[[REG]]
90 define i8 @test6(i8 %a, i8 %b) nounwind {
94 %b_addr.0 = phi i8 [ %b, %entry ], [ %tmp8, %bb ]
95 %a_addr.0 = phi i8 [ %a, %entry ], [ %tmp3, %bb ]
96 %tmp3 = xor i8 %a_addr.0, %b_addr.0
97 %tmp4not = xor i8 %tmp3, 127
98 %tmp6 = and i8 %tmp4not, %b_addr.0
99 %tmp8 = shl i8 %tmp6, 1
100 %tmp10 = icmp eq i8 %tmp8, 0
101 br i1 %tmp10, label %bb12, label %bb
105 ; X64: notb [[REG:%[a-z]+]]
106 ; X64: andb {{.*}}[[REG]]
108 ; X32: notb [[REG:%[a-z]+]]
109 ; X32: andb {{.*}}[[REG]]
112 define i32 @test7(i32 %a, i32 %b) nounwind {
116 %b_addr.0 = phi i32 [ %b, %entry ], [ %tmp8, %bb ]
117 %a_addr.0 = phi i32 [ %a, %entry ], [ %tmp3, %bb ]
118 %tmp3 = xor i32 %a_addr.0, %b_addr.0
119 %tmp4not = xor i32 %tmp3, 2147483646
120 %tmp6 = and i32 %tmp4not, %b_addr.0
121 %tmp8 = shl i32 %tmp6, 1
122 %tmp10 = icmp eq i32 %tmp8, 0
123 br i1 %tmp10, label %bb12, label %bb
127 ; X64: xorl $2147483646, [[REG:%[a-z]+]]
128 ; X64: andl {{.*}}[[REG]]
130 ; X32: xorl $2147483646, [[REG:%[a-z]+]]
131 ; X32: andl {{.*}}[[REG]]
134 define i32 @test8(i32 %a) nounwind {
138 %t2 = add i32 %t1, -1
141 ; X64: notl {{%eax|%edi|%ecx}}
146 define i32 @test9(i32 %a) nounwind {
147 %1 = and i32 %a, 4096
148 %2 = xor i32 %1, 4096
151 ; X64: notl [[REG:%[a-z]+]]
152 ; X64: andl {{.*}}[[REG:%[a-z]+]]
154 ; X32: notl [[REG:%[a-z]+]]
155 ; X32: andl {{.*}}[[REG:%[a-z]+]]
159 define <4 x i32> @test10(<4 x i32> %a) nounwind {
160 %1 = and <4 x i32> %a, <i32 4096, i32 4096, i32 4096, i32 4096>
161 %2 = xor <4 x i32> %1, <i32 4096, i32 4096, i32 4096, i32 4096>
169 define i32 @PR17487(i1 %tobool) {
170 %tmp = insertelement <2 x i1> undef, i1 %tobool, i32 1
171 %tmp1 = zext <2 x i1> %tmp to <2 x i64>
172 %tmp2 = xor <2 x i64> %tmp1, <i64 1, i64 1>
173 %tmp3 = extractelement <2 x i64> %tmp2, i32 1
174 %add = add nsw i64 0, %tmp3
175 %cmp6 = icmp ne i64 %add, 1
176 %conv7 = zext i1 %cmp6 to i32
179 ; X64-LABEL: PR17487:
181 ; X32-LABEL: PR17487:
185 define i32 @test11(i32 %b) {
187 %neg = xor i32 %shl, -1
190 ; X64: movl $-2, %[[REG:.*]]
191 ; X64: roll %{{.*}}, %[[REG]]
193 ; X32: movl $-2, %[[REG:.*]]
194 ; X32: roll %{{.*}}, %[[REG]]