Jim Grosbach | 469bbdb | 2010-07-16 23:05:05 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=thumb -mattr=+v6t2 < %s | FileCheck %s |
| 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: movs r2, #10 |
| 11 | ; CHECK: bfi r1, r2, #22, #4 |
| 12 | %0 = load i32* bitcast (%struct.F* @X to i32*), align 4 ; <i32> [#uses=1] |
| 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 | 5423856 | 2010-07-17 03:30:54 +0000 | [diff] [blame] | 18 | |
| 19 | define i32 @f2(i32 %A, i32 %B) nounwind readnone optsize { |
| 20 | entry: |
| 21 | ; CHECK: f2 |
| 22 | ; CHECK: lsrs r1, r1, #7 |
| 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 | |
| 30 | define i32 @f3(i32 %A, i32 %B) nounwind readnone optsize { |
| 31 | entry: |
| 32 | ; CHECK: f3 |
| 33 | ; CHECK: lsrs r2, r0, #7 |
| 34 | ; CHECK: mov r0, r1 |
| 35 | ; CHECK: bfi r0, r2, #7, #16 |
| 36 | %and = and i32 %A, 8388480 ; <i32> [#uses=1] |
| 37 | %and2 = and i32 %B, -8388481 ; <i32> [#uses=1] |
| 38 | %or = or i32 %and2, %and ; <i32> [#uses=1] |
| 39 | ret i32 %or |
| 40 | } |
Evan Cheng | a9688c4 | 2010-12-11 04:11:38 +0000 | [diff] [blame] | 41 | |
| 42 | ; rdar://8752056 |
| 43 | define i32 @f4(i32 %a) nounwind { |
| 44 | ; CHECK: f4 |
| 45 | ; CHECK: movw r1, #3137 |
| 46 | ; CHECK: bfi r1, r0, #15, #5 |
| 47 | %1 = shl i32 %a, 15 |
| 48 | %ins7 = and i32 %1, 1015808 |
| 49 | %ins12 = or i32 %ins7, 3137 |
| 50 | ret i32 %ins12 |
| 51 | } |
Eric Christopher | 29aeed1 | 2011-03-26 01:21:03 +0000 | [diff] [blame] | 52 | |
| 53 | ; rdar://9177502 |
| 54 | define i32 @f5(i32 %a, i32 %b) nounwind readnone { |
| 55 | entry: |
Benjamin Kramer | a42a757 | 2011-04-25 10:12:01 +0000 | [diff] [blame] | 56 | ; CHECK: f5 |
Eric Christopher | 29aeed1 | 2011-03-26 01:21:03 +0000 | [diff] [blame] | 57 | ; CHECK-NOT: bfi r0, r2, #0, #1 |
| 58 | %and = and i32 %a, 2 |
| 59 | %b.masked = and i32 %b, -2 |
| 60 | %and3 = or i32 %b.masked, %and |
| 61 | ret i32 %and3 |
| 62 | } |