Jim Grosbach | 9f07f3b | 2009-11-16 23:19:29 +0000 | [diff] [blame^] | 1 | ; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s |
| 2 | ; xRUN: llc < %s -march=thumb -mattr=+thumb2 | grep lsl |
| 3 | ; xRUN: llc < %s -march=thumb -mattr=+thumb2 | grep lsr |
| 4 | ; xRUN: llc < %s -march=thumb -mattr=+thumb2 | grep asr |
| 5 | ; xRUN: llc < %s -march=thumb -mattr=+thumb2 | grep ror |
| 6 | ; xRUN: llc < %s -march=thumb -mattr=+thumb2 | not grep mov |
Anton Korobeynikov | 5223711 | 2009-06-17 18:13:58 +0000 | [diff] [blame] | 7 | |
| 8 | define i32 @t2ADDrs_lsl(i32 %X, i32 %Y) { |
Jim Grosbach | 9f07f3b | 2009-11-16 23:19:29 +0000 | [diff] [blame^] | 9 | ; CHECK: t2ADDrs_lsl |
| 10 | ; CHECK: add.w r0, r0, r1, lsl #16 |
Anton Korobeynikov | 5223711 | 2009-06-17 18:13:58 +0000 | [diff] [blame] | 11 | %A = shl i32 %Y, 16 |
| 12 | %B = add i32 %X, %A |
| 13 | ret i32 %B |
| 14 | } |
| 15 | |
| 16 | define i32 @t2ADDrs_lsr(i32 %X, i32 %Y) { |
Jim Grosbach | 9f07f3b | 2009-11-16 23:19:29 +0000 | [diff] [blame^] | 17 | ; CHECK: t2ADDrs_lsr |
| 18 | ; CHECK: add.w r0, r0, r1, lsr #16 |
Anton Korobeynikov | 5223711 | 2009-06-17 18:13:58 +0000 | [diff] [blame] | 19 | %A = lshr i32 %Y, 16 |
| 20 | %B = add i32 %X, %A |
| 21 | ret i32 %B |
| 22 | } |
| 23 | |
| 24 | define i32 @t2ADDrs_asr(i32 %X, i32 %Y) { |
Jim Grosbach | 9f07f3b | 2009-11-16 23:19:29 +0000 | [diff] [blame^] | 25 | ; CHECK: t2ADDrs_asr |
| 26 | ; CHECK: add.w r0, r0, r1, asr #16 |
Anton Korobeynikov | 5223711 | 2009-06-17 18:13:58 +0000 | [diff] [blame] | 27 | %A = ashr i32 %Y, 16 |
| 28 | %B = add i32 %X, %A |
| 29 | ret i32 %B |
| 30 | } |
| 31 | |
| 32 | ; i32 ror(n) = (x >> n) | (x << (32 - n)) |
| 33 | define i32 @t2ADDrs_ror(i32 %X, i32 %Y) { |
Jim Grosbach | 9f07f3b | 2009-11-16 23:19:29 +0000 | [diff] [blame^] | 34 | ; CHECK: t2ADDrs_ror |
| 35 | ; CHECK: add.w r0, r0, r1, ror #16 |
Anton Korobeynikov | 5223711 | 2009-06-17 18:13:58 +0000 | [diff] [blame] | 36 | %A = lshr i32 %Y, 16 |
| 37 | %B = shl i32 %Y, 16 |
| 38 | %C = or i32 %B, %A |
| 39 | %R = add i32 %X, %C |
| 40 | ret i32 %R |
| 41 | } |
| 42 | |
| 43 | define i32 @t2ADDrs_noRegShift(i32 %X, i32 %Y, i8 %sh) { |
Jim Grosbach | 9f07f3b | 2009-11-16 23:19:29 +0000 | [diff] [blame^] | 44 | ; CHECK: t2ADDrs_noRegShift |
| 45 | ; CHECK: uxtb r2, r2 |
| 46 | ; CHECK: lsls r1, r2 |
| 47 | ; CHECK: add r0, r1 |
Anton Korobeynikov | 5223711 | 2009-06-17 18:13:58 +0000 | [diff] [blame] | 48 | %shift.upgrd.1 = zext i8 %sh to i32 |
| 49 | %A = shl i32 %Y, %shift.upgrd.1 |
| 50 | %B = add i32 %X, %A |
| 51 | ret i32 %B |
| 52 | } |
| 53 | |