Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 1 | ; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s |
Chris Lattner | 994d6cf | 2008-01-18 19:53:43 +0000 | [diff] [blame] | 2 | ; RUN: grep eqv %t1.s | count 18 |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 3 | |
| 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 Michel | 9de5d0d | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 10 | target 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" |
| 11 | target triple = "spu" |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 12 | |
| 13 | define <4 x i32> @equiv_v4i32_1(<4 x i32> %arg1, <4 x i32> %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 14 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | define <4 x i32> @equiv_v4i32_2(<4 x i32> %arg1, <4 x i32> %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 22 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | define <4 x i32> @equiv_v4i32_3(<4 x i32> %arg1, <4 x i32> %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 30 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | define <4 x i32> @equiv_v4i32_4(<4 x i32> %arg1, <4 x i32> %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 38 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | define i32 @equiv_i32_1(i32 %arg1, i32 %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 44 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | define i32 @equiv_i32_2(i32 %arg1, i32 %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 52 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | define i32 @equiv_i32_3(i32 %arg1, i32 %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 60 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | define i32 @equiv_i32_4(i32 %arg1, i32 %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 68 | %arg2not = xor i32 %arg2, -1 |
| 69 | %C = xor i32 %arg1, %arg2not |
| 70 | ret i32 %C |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | define i32 @equiv_i32_5(i32 %arg1, i32 %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 74 | %arg1not = xor i32 %arg1, -1 |
| 75 | %C = xor i32 %arg2, %arg1not |
| 76 | ret i32 %C |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | define i16 @equiv_i16_1(i16 signext %arg1, i16 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 80 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | define i16 @equiv_i16_2(i16 signext %arg1, i16 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 88 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | define i16 @equiv_i16_3(i16 signext %arg1, i16 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 96 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | define i8 @equiv_i8_1(i8 signext %arg1, i8 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 104 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | define i8 @equiv_i8_2(i8 signext %arg1, i8 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 112 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | define i8 @equiv_i8_3(i8 signext %arg1, i8 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 120 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | define i8 @equiv_u8_1(i8 zeroext %arg1, i8 zeroext %arg2) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 128 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | define i8 @equiv_u8_2(i8 zeroext %arg1, i8 zeroext %arg2) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 136 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | define i8 @equiv_u8_3(i8 zeroext %arg1, i8 zeroext %arg2) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 144 | %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 Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 149 | } |