Saleem Abdulrasool | 7258735 | 2014-04-03 16:01:44 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=arm -mattr=+v6t2 %s -o - | FileCheck %s |
Jim Grosbach | 11013ed | 2010-07-16 23:05:05 +0000 | [diff] [blame] | 2 | |
| 3 | %struct.F = type { [3 x i8], i8 } |
| 4 | |
| 5 | @X = common global %struct.F zeroinitializer, align 4 ; <%struct.F*> [#uses=1] |
| 6 | |
| 7 | define void @f1([1 x i32] %f.coerce0) nounwind { |
| 8 | entry: |
| 9 | ; CHECK: f1 |
| 10 | ; CHECK: mov r2, #10 |
| 11 | ; CHECK: bfi r1, r2, #22, #4 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 12 | %0 = load i32, i32* bitcast (%struct.F* @X to i32*), align 4 ; <i32> [#uses=1] |
Jim Grosbach | 11013ed | 2010-07-16 23:05:05 +0000 | [diff] [blame] | 13 | %1 = and i32 %0, -62914561 ; <i32> [#uses=1] |
| 14 | %2 = or i32 %1, 41943040 ; <i32> [#uses=1] |
| 15 | store i32 %2, i32* bitcast (%struct.F* @X to i32*), align 4 |
| 16 | ret void |
| 17 | } |
Jim Grosbach | b97e2bb | 2010-07-17 03:30:54 +0000 | [diff] [blame] | 18 | |
Evan Cheng | 3434575 | 2010-12-11 04:11:38 +0000 | [diff] [blame] | 19 | define i32 @f2(i32 %A, i32 %B) nounwind { |
Jim Grosbach | b97e2bb | 2010-07-17 03:30:54 +0000 | [diff] [blame] | 20 | entry: |
| 21 | ; CHECK: f2 |
Jim Grosbach | 6d800f8 | 2010-09-17 21:58:46 +0000 | [diff] [blame] | 22 | ; CHECK: lsr{{.*}}#7 |
Jim Grosbach | b97e2bb | 2010-07-17 03:30:54 +0000 | [diff] [blame] | 23 | ; CHECK: bfi r0, r1, #7, #16 |
| 24 | %and = and i32 %A, -8388481 ; <i32> [#uses=1] |
| 25 | %and2 = and i32 %B, 8388480 ; <i32> [#uses=1] |
| 26 | %or = or i32 %and2, %and ; <i32> [#uses=1] |
| 27 | ret i32 %or |
| 28 | } |
| 29 | |
Evan Cheng | 3434575 | 2010-12-11 04:11:38 +0000 | [diff] [blame] | 30 | define i32 @f3(i32 %A, i32 %B) nounwind { |
Jim Grosbach | b97e2bb | 2010-07-17 03:30:54 +0000 | [diff] [blame] | 31 | entry: |
| 32 | ; CHECK: f3 |
Jim Grosbach | 6d800f8 | 2010-09-17 21:58:46 +0000 | [diff] [blame] | 33 | ; CHECK: lsr{{.*}} #7 |
Jakob Stoklund Olesen | 51b35f7 | 2011-05-03 22:31:21 +0000 | [diff] [blame] | 34 | ; CHECK: bfi {{.*}}, #7, #16 |
Jim Grosbach | b97e2bb | 2010-07-17 03:30:54 +0000 | [diff] [blame] | 35 | %and = and i32 %A, 8388480 ; <i32> [#uses=1] |
| 36 | %and2 = and i32 %B, -8388481 ; <i32> [#uses=1] |
| 37 | %or = or i32 %and2, %and ; <i32> [#uses=1] |
| 38 | ret i32 %or |
| 39 | } |
Evan Cheng | 3434575 | 2010-12-11 04:11:38 +0000 | [diff] [blame] | 40 | |
| 41 | ; rdar://8752056 |
| 42 | define i32 @f4(i32 %a) nounwind { |
| 43 | ; CHECK: f4 |
Jakob Stoklund Olesen | 51b35f7 | 2011-05-03 22:31:21 +0000 | [diff] [blame] | 44 | ; CHECK: movw [[R1:r[0-9]+]], #3137 |
| 45 | ; CHECK: bfi [[R1]], {{r[0-9]+}}, #15, #5 |
Evan Cheng | 3434575 | 2010-12-11 04:11:38 +0000 | [diff] [blame] | 46 | %1 = shl i32 %a, 15 |
| 47 | %ins7 = and i32 %1, 1015808 |
| 48 | %ins12 = or i32 %ins7, 3137 |
| 49 | ret i32 %ins12 |
| 50 | } |
Evan Cheng | c177813 | 2010-12-14 03:22:07 +0000 | [diff] [blame] | 51 | |
| 52 | ; rdar://8458663 |
| 53 | define i32 @f5(i32 %a, i32 %b) nounwind { |
| 54 | entry: |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 55 | ; CHECK-LABEL: f5: |
Evan Cheng | c177813 | 2010-12-14 03:22:07 +0000 | [diff] [blame] | 56 | ; CHECK-NOT: bfc |
| 57 | ; CHECK: bfi r0, r1, #20, #4 |
| 58 | %0 = and i32 %a, -15728641 |
| 59 | %1 = shl i32 %b, 20 |
| 60 | %2 = and i32 %1, 15728640 |
| 61 | %3 = or i32 %2, %0 |
| 62 | ret i32 %3 |
| 63 | } |
Evan Cheng | 6d02d90 | 2011-06-15 01:12:31 +0000 | [diff] [blame] | 64 | |
| 65 | ; rdar://9609030 |
| 66 | define i32 @f6(i32 %a, i32 %b) nounwind readnone { |
| 67 | entry: |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 68 | ; CHECK-LABEL: f6: |
Evan Cheng | 6d02d90 | 2011-06-15 01:12:31 +0000 | [diff] [blame] | 69 | ; CHECK-NOT: bic |
| 70 | ; CHECK: bfi r0, r1, #8, #9 |
| 71 | %and = and i32 %a, -130817 |
| 72 | %and2 = shl i32 %b, 8 |
| 73 | %shl = and i32 %and2, 130816 |
| 74 | %or = or i32 %shl, %and |
| 75 | ret i32 %or |
| 76 | } |
James Molloy | 9d55f19 | 2015-11-10 14:22:05 +0000 | [diff] [blame] | 77 | |
| 78 | define i32 @f7(i32 %x, i32 %y) { |
| 79 | ; CHECK-LABEL: f7: |
| 80 | ; CHECK: bfi r1, r0, #4, #1 |
| 81 | %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 |
| 82 | %and = and i32 %x, 4 |
| 83 | %or = or i32 %y2, 16 |
| 84 | %cmp = icmp ne i32 %and, 0 |
| 85 | %sel = select i1 %cmp, i32 %or, i32 %y2 |
| 86 | ret i32 %sel |
| 87 | } |
| 88 | |
| 89 | define i32 @f8(i32 %x, i32 %y) { |
| 90 | ; CHECK-LABEL: f8: |
| 91 | ; CHECK: bfi r1, r0, #4, #1 |
| 92 | ; CHECK: bfi r1, r0, #5, #1 |
| 93 | %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 |
| 94 | %and = and i32 %x, 4 |
| 95 | %or = or i32 %y2, 48 |
| 96 | %cmp = icmp ne i32 %and, 0 |
| 97 | %sel = select i1 %cmp, i32 %or, i32 %y2 |
| 98 | ret i32 %sel |
| 99 | } |
| 100 | |
| 101 | define i32 @f9(i32 %x, i32 %y) { |
| 102 | ; CHECK-LABEL: f9: |
| 103 | ; CHECK-NOT: bfi |
| 104 | %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 |
| 105 | %and = and i32 %x, 4 |
| 106 | %or = or i32 %y2, 48 |
| 107 | %cmp = icmp ne i32 %and, 0 |
| 108 | %sel = select i1 %cmp, i32 %y2, i32 %or |
| 109 | ret i32 %sel |
| 110 | } |
James Molloy | ce12c92 | 2015-11-11 15:40:40 +0000 | [diff] [blame] | 111 | |
| 112 | define i32 @f10(i32 %x, i32 %y) { |
| 113 | ; CHECK-LABEL: f10: |
| 114 | ; CHECK: bfi r1, r0, #4, #2 |
| 115 | %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 |
| 116 | %and = and i32 %x, 4 |
| 117 | %or = or i32 %y2, 32 |
| 118 | %cmp = icmp ne i32 %and, 0 |
| 119 | %sel = select i1 %cmp, i32 %or, i32 %y2 |
| 120 | |
| 121 | %aand = and i32 %x, 2 |
| 122 | %aor = or i32 %sel, 16 |
| 123 | %acmp = icmp ne i32 %aand, 0 |
| 124 | %asel = select i1 %acmp, i32 %aor, i32 %sel |
| 125 | |
| 126 | ret i32 %asel |
| 127 | } |
| 128 | |
| 129 | define i32 @f11(i32 %x, i32 %y) { |
| 130 | ; CHECK-LABEL: f11: |
| 131 | ; CHECK: bfi r1, r0, #4, #3 |
| 132 | %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 |
| 133 | %and = and i32 %x, 4 |
| 134 | %or = or i32 %y2, 32 |
| 135 | %cmp = icmp ne i32 %and, 0 |
| 136 | %sel = select i1 %cmp, i32 %or, i32 %y2 |
| 137 | |
| 138 | %aand = and i32 %x, 2 |
| 139 | %aor = or i32 %sel, 16 |
| 140 | %acmp = icmp ne i32 %aand, 0 |
| 141 | %asel = select i1 %acmp, i32 %aor, i32 %sel |
| 142 | |
| 143 | %band = and i32 %x, 8 |
| 144 | %bor = or i32 %asel, 64 |
| 145 | %bcmp = icmp ne i32 %band, 0 |
| 146 | %bsel = select i1 %bcmp, i32 %bor, i32 %asel |
| 147 | |
| 148 | ret i32 %bsel |
| 149 | } |
James Molloy | 8e99e97 | 2015-11-12 13:49:17 +0000 | [diff] [blame] | 150 | |
| 151 | define i32 @f12(i32 %x, i32 %y) { |
| 152 | ; CHECK-LABEL: f12: |
| 153 | ; CHECK: bfi r1, r0, #4, #1 |
| 154 | %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 |
| 155 | %and = and i32 %x, 4 |
| 156 | %or = or i32 %y2, 16 |
| 157 | %cmp = icmp eq i32 %and, 0 |
| 158 | %sel = select i1 %cmp, i32 %y2, i32 %or |
| 159 | ret i32 %sel |
| 160 | } |
James Molloy | 2018091 | 2015-11-16 10:49:25 +0000 | [diff] [blame] | 161 | |
| 162 | define i32 @f13(i32 %x, i32 %y) { |
| 163 | ; CHECK-LABEL: f13: |
| 164 | ; CHECK-NOT: bfi |
| 165 | %y2 = and i32 %y, 4294967040 ; 0xFFFFFF00 |
| 166 | %and = and i32 %x, 4 |
| 167 | %or = or i32 %y2, 16 |
| 168 | %cmp = icmp eq i32 %and, 42 ; Not comparing against zero! |
| 169 | %sel = select i1 %cmp, i32 %y2, i32 %or |
| 170 | ret i32 %sel |
| 171 | } |