The AND instruction leaves the V flag unmodified, so it falls victim to the same
[oota-llvm.git] / test / CodeGen / X86 / xor.ll
1 ; RUN: llc < %s -march=x86 -mattr=+sse2  | FileCheck %s -check-prefix=X32
2 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s -check-prefix=X64
3 ; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s -check-prefix=X64
4
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
8         ret <4 x i32> %tmp
9         
10 ; X32: test1:
11 ; X32:  pxor    %xmm0, %xmm0
12 ; X32:  ret
13 }
14
15 ; Though it is undefined, we want xor undef,undef to produce zero.
16 define i32 @test2() nounwind{
17         %tmp = xor i32 undef, undef
18         ret i32 %tmp
19 ; X32: test2:
20 ; X32:  xorl    %eax, %eax
21 ; X32:  ret
22 }
23
24 define i32 @test3(i32 %a, i32 %b) nounwind  {
25 entry:
26         %tmp1not = xor i32 %b, -2
27         %tmp3 = and i32 %tmp1not, %a
28         %tmp4 = lshr i32 %tmp3, 1
29         ret i32 %tmp4
30         
31 ; X64: test3:
32 ; X64:  notl    [[A1:%esi|%edx]]
33 ; X64:  andl    [[A0:%edi|%ecx]], [[A1]]
34 ; X64:  movl    [[A1]], %eax
35 ; X64:  shrl    %eax
36 ; X64:  ret
37
38 ; X32: test3:
39 ; X32:  movl    8(%esp), %eax
40 ; X32:  notl    %eax
41 ; X32:  andl    4(%esp), %eax
42 ; X32:  shrl    %eax
43 ; X32:  ret
44 }
45
46 define i32 @test4(i32 %a, i32 %b) nounwind  {
47 entry:
48         br label %bb
49 bb:
50         %b_addr.0 = phi i32 [ %b, %entry ], [ %tmp8, %bb ]
51         %a_addr.0 = phi i32 [ %a, %entry ], [ %tmp3, %bb ]
52         %tmp3 = xor i32 %a_addr.0, %b_addr.0
53         %tmp4not = xor i32 %tmp3, 2147483647
54         %tmp6 = and i32 %tmp4not, %b_addr.0
55         %tmp8 = shl i32 %tmp6, 1
56         %tmp10 = icmp eq i32 %tmp8, 0
57         br i1 %tmp10, label %bb12, label %bb
58 bb12:
59         ret i32 %tmp3
60         
61 ; X64: test4:
62 ; X64:    notl  [[REG:%[a-z]+]]
63 ; X64:    andl  {{.*}}[[REG]]
64 ; X32: test4:
65 ; X32:    notl  [[REG:%[a-z]+]]
66 ; X32:    andl  {{.*}}[[REG]]
67 }
68
69 define i16 @test5(i16 %a, i16 %b) nounwind  {
70 entry:
71         br label %bb
72 bb:
73         %b_addr.0 = phi i16 [ %b, %entry ], [ %tmp8, %bb ]
74         %a_addr.0 = phi i16 [ %a, %entry ], [ %tmp3, %bb ]
75         %tmp3 = xor i16 %a_addr.0, %b_addr.0
76         %tmp4not = xor i16 %tmp3, 32767
77         %tmp6 = and i16 %tmp4not, %b_addr.0
78         %tmp8 = shl i16 %tmp6, 1
79         %tmp10 = icmp eq i16 %tmp8, 0
80         br i1 %tmp10, label %bb12, label %bb
81 bb12:
82         ret i16 %tmp3
83 ; X64: test5:
84 ; X64:    notl  [[REG:%[a-z]+]]
85 ; X64:    andl  {{.*}}[[REG]]
86 ; X32: test5:
87 ; X32:    notl  [[REG:%[a-z]+]]
88 ; X32:    andl  {{.*}}[[REG]]
89 }
90
91 define i8 @test6(i8 %a, i8 %b) nounwind  {
92 entry:
93         br label %bb
94 bb:
95         %b_addr.0 = phi i8 [ %b, %entry ], [ %tmp8, %bb ]
96         %a_addr.0 = phi i8 [ %a, %entry ], [ %tmp3, %bb ]
97         %tmp3 = xor i8 %a_addr.0, %b_addr.0
98         %tmp4not = xor i8 %tmp3, 127
99         %tmp6 = and i8 %tmp4not, %b_addr.0
100         %tmp8 = shl i8 %tmp6, 1
101         %tmp10 = icmp eq i8 %tmp8, 0
102         br i1 %tmp10, label %bb12, label %bb
103 bb12:
104         ret i8 %tmp3
105 ; X64: test6:
106 ; X64:    notb  [[REG:%[a-z]+]]
107 ; X64:    andb  {{.*}}[[REG]]
108 ; X32: test6:
109 ; X32:    notb  [[REG:%[a-z]+]]
110 ; X32:    andb  {{.*}}[[REG]]
111 }
112
113 define i32 @test7(i32 %a, i32 %b) nounwind  {
114 entry:
115         br label %bb
116 bb:
117         %b_addr.0 = phi i32 [ %b, %entry ], [ %tmp8, %bb ]
118         %a_addr.0 = phi i32 [ %a, %entry ], [ %tmp3, %bb ]
119         %tmp3 = xor i32 %a_addr.0, %b_addr.0
120         %tmp4not = xor i32 %tmp3, 2147483646
121         %tmp6 = and i32 %tmp4not, %b_addr.0
122         %tmp8 = shl i32 %tmp6, 1
123         %tmp10 = icmp eq i32 %tmp8, 0
124         br i1 %tmp10, label %bb12, label %bb
125 bb12:
126         ret i32 %tmp3
127 ; X64: test7:
128 ; X64:    xorl  $2147483646, [[REG:%[a-z]+]]
129 ; X64:    andl  {{.*}}[[REG]]
130 ; X32: test7:
131 ; X32:    xorl  $2147483646, [[REG:%[a-z]+]]
132 ; X32:    andl  {{.*}}[[REG]]
133 }
134
135 define i32 @test8(i32 %a) nounwind {
136 ; rdar://7553032
137 entry:
138   %t1 = sub i32 0, %a
139   %t2 = add i32 %t1, -1
140   ret i32 %t2
141 ; X64: test8:
142 ; X64:   notl %eax
143 ; X32: test8:
144 ; X32:   notl %eax
145 }