blob: a578315c6b045a324de743968346090829084764 [file] [log] [blame]
Scott Michel0a92af42007-12-19 20:50:49 +00001; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s
Chris Lattner994d6cf2008-01-18 19:53:43 +00002; RUN: grep eqv %t1.s | count 18
Scott Michel0a92af42007-12-19 20:50:49 +00003
4; Test the 'eqv' instruction, whose boolean expression is:
5; (a & b) | (~a & ~b), which simplifies to
6; (a & b) | ~(a | b)
7; Alternatively, a ^ ~b, which the compiler will also match.
8
9; ModuleID = 'eqv.bc'
Scott Michel9de5d0d2008-01-11 02:53:15 +000010target datalayout = "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128-i16:16:128-i8:8:128-i1:8:128-a0:0:128-v128:128:128-s0:128:128"
11target triple = "spu"
Scott Michel0a92af42007-12-19 20:50:49 +000012
13define <4 x i32> @equiv_v4i32_1(<4 x i32> %arg1, <4 x i32> %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000014 %A = and <4 x i32> %arg1, %arg2
15 %B = or <4 x i32> %arg1, %arg2
16 %Bnot = xor <4 x i32> %B, < i32 -1, i32 -1, i32 -1, i32 -1 >
17 %C = or <4 x i32> %A, %Bnot
18 ret <4 x i32> %C
Scott Michel0a92af42007-12-19 20:50:49 +000019}
20
21define <4 x i32> @equiv_v4i32_2(<4 x i32> %arg1, <4 x i32> %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000022 %B = or <4 x i32> %arg1, %arg2 ; <<4 x i32>> [#uses=1]
23 %Bnot = xor <4 x i32> %B, < i32 -1, i32 -1, i32 -1, i32 -1 > ; <<4 x i32>> [#uses=1]
24 %A = and <4 x i32> %arg1, %arg2 ; <<4 x i32>> [#uses=1]
25 %C = or <4 x i32> %A, %Bnot ; <<4 x i32>> [#uses=1]
26 ret <4 x i32> %C
Scott Michel0a92af42007-12-19 20:50:49 +000027}
28
29define <4 x i32> @equiv_v4i32_3(<4 x i32> %arg1, <4 x i32> %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000030 %B = or <4 x i32> %arg1, %arg2 ; <<4 x i32>> [#uses=1]
31 %A = and <4 x i32> %arg1, %arg2 ; <<4 x i32>> [#uses=1]
32 %Bnot = xor <4 x i32> %B, < i32 -1, i32 -1, i32 -1, i32 -1 > ; <<4 x i32>> [#uses=1]
33 %C = or <4 x i32> %A, %Bnot ; <<4 x i32>> [#uses=1]
34 ret <4 x i32> %C
Scott Michel0a92af42007-12-19 20:50:49 +000035}
36
37define <4 x i32> @equiv_v4i32_4(<4 x i32> %arg1, <4 x i32> %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000038 %arg2not = xor <4 x i32> %arg2, < i32 -1, i32 -1, i32 -1, i32 -1 >
39 %C = xor <4 x i32> %arg1, %arg2not
40 ret <4 x i32> %C
Scott Michel0a92af42007-12-19 20:50:49 +000041}
42
43define i32 @equiv_i32_1(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000044 %A = and i32 %arg1, %arg2 ; <i32> [#uses=1]
45 %B = or i32 %arg1, %arg2 ; <i32> [#uses=1]
46 %Bnot = xor i32 %B, -1 ; <i32> [#uses=1]
47 %C = or i32 %A, %Bnot ; <i32> [#uses=1]
48 ret i32 %C
Scott Michel0a92af42007-12-19 20:50:49 +000049}
50
51define i32 @equiv_i32_2(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000052 %B = or i32 %arg1, %arg2 ; <i32> [#uses=1]
53 %Bnot = xor i32 %B, -1 ; <i32> [#uses=1]
54 %A = and i32 %arg1, %arg2 ; <i32> [#uses=1]
55 %C = or i32 %A, %Bnot ; <i32> [#uses=1]
56 ret i32 %C
Scott Michel0a92af42007-12-19 20:50:49 +000057}
58
59define i32 @equiv_i32_3(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000060 %B = or i32 %arg1, %arg2 ; <i32> [#uses=1]
61 %A = and i32 %arg1, %arg2 ; <i32> [#uses=1]
62 %Bnot = xor i32 %B, -1 ; <i32> [#uses=1]
63 %C = or i32 %A, %Bnot ; <i32> [#uses=1]
64 ret i32 %C
Scott Michel0a92af42007-12-19 20:50:49 +000065}
66
67define i32 @equiv_i32_4(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000068 %arg2not = xor i32 %arg2, -1
69 %C = xor i32 %arg1, %arg2not
70 ret i32 %C
Scott Michel0a92af42007-12-19 20:50:49 +000071}
72
73define i32 @equiv_i32_5(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000074 %arg1not = xor i32 %arg1, -1
75 %C = xor i32 %arg2, %arg1not
76 ret i32 %C
Scott Michel0a92af42007-12-19 20:50:49 +000077}
78
79define i16 @equiv_i16_1(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000080 %A = and i16 %arg1, %arg2 ; <i16> [#uses=1]
81 %B = or i16 %arg1, %arg2 ; <i16> [#uses=1]
82 %Bnot = xor i16 %B, -1 ; <i16> [#uses=1]
83 %C = or i16 %A, %Bnot ; <i16> [#uses=1]
84 ret i16 %C
Scott Michel0a92af42007-12-19 20:50:49 +000085}
86
87define i16 @equiv_i16_2(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000088 %B = or i16 %arg1, %arg2 ; <i16> [#uses=1]
89 %Bnot = xor i16 %B, -1 ; <i16> [#uses=1]
90 %A = and i16 %arg1, %arg2 ; <i16> [#uses=1]
91 %C = or i16 %A, %Bnot ; <i16> [#uses=1]
92 ret i16 %C
Scott Michel0a92af42007-12-19 20:50:49 +000093}
94
95define i16 @equiv_i16_3(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000096 %B = or i16 %arg1, %arg2 ; <i16> [#uses=1]
97 %A = and i16 %arg1, %arg2 ; <i16> [#uses=1]
98 %Bnot = xor i16 %B, -1 ; <i16> [#uses=1]
99 %C = or i16 %A, %Bnot ; <i16> [#uses=1]
100 ret i16 %C
Scott Michel0a92af42007-12-19 20:50:49 +0000101}
102
103define i8 @equiv_i8_1(i8 signext %arg1, i8 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000104 %A = and i8 %arg1, %arg2 ; <i8> [#uses=1]
105 %B = or i8 %arg1, %arg2 ; <i8> [#uses=1]
106 %Bnot = xor i8 %B, -1 ; <i8> [#uses=1]
107 %C = or i8 %A, %Bnot ; <i8> [#uses=1]
108 ret i8 %C
Scott Michel0a92af42007-12-19 20:50:49 +0000109}
110
111define i8 @equiv_i8_2(i8 signext %arg1, i8 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000112 %B = or i8 %arg1, %arg2 ; <i8> [#uses=1]
113 %Bnot = xor i8 %B, -1 ; <i8> [#uses=1]
114 %A = and i8 %arg1, %arg2 ; <i8> [#uses=1]
115 %C = or i8 %A, %Bnot ; <i8> [#uses=1]
116 ret i8 %C
Scott Michel0a92af42007-12-19 20:50:49 +0000117}
118
119define i8 @equiv_i8_3(i8 signext %arg1, i8 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000120 %B = or i8 %arg1, %arg2 ; <i8> [#uses=1]
121 %A = and i8 %arg1, %arg2 ; <i8> [#uses=1]
122 %Bnot = xor i8 %B, -1 ; <i8> [#uses=1]
123 %C = or i8 %A, %Bnot ; <i8> [#uses=1]
124 ret i8 %C
Scott Michel0a92af42007-12-19 20:50:49 +0000125}
126
127define i8 @equiv_u8_1(i8 zeroext %arg1, i8 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000128 %A = and i8 %arg1, %arg2 ; <i8> [#uses=1]
129 %B = or i8 %arg1, %arg2 ; <i8> [#uses=1]
130 %Bnot = xor i8 %B, -1 ; <i8> [#uses=1]
131 %C = or i8 %A, %Bnot ; <i8> [#uses=1]
132 ret i8 %C
Scott Michel0a92af42007-12-19 20:50:49 +0000133}
134
135define i8 @equiv_u8_2(i8 zeroext %arg1, i8 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000136 %B = or i8 %arg1, %arg2 ; <i8> [#uses=1]
137 %Bnot = xor i8 %B, -1 ; <i8> [#uses=1]
138 %A = and i8 %arg1, %arg2 ; <i8> [#uses=1]
139 %C = or i8 %A, %Bnot ; <i8> [#uses=1]
140 ret i8 %C
Scott Michel0a92af42007-12-19 20:50:49 +0000141}
142
143define i8 @equiv_u8_3(i8 zeroext %arg1, i8 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000144 %B = or i8 %arg1, %arg2 ; <i8> [#uses=1]
145 %A = and i8 %arg1, %arg2 ; <i8> [#uses=1]
146 %Bnot = xor i8 %B, -1 ; <i8> [#uses=1]
147 %C = or i8 %A, %Bnot ; <i8> [#uses=1]
148 ret i8 %C
Scott Michel0a92af42007-12-19 20:50:49 +0000149}