blob: 319b7648e38d1ae609a9b85278e90f1672e137ac [file] [log] [blame]
Jim Grosbach9f07f3b2009-11-16 23:19:29 +00001; 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 Korobeynikov52237112009-06-17 18:13:58 +00007
8define i32 @t2ADDrs_lsl(i32 %X, i32 %Y) {
Jim Grosbach9f07f3b2009-11-16 23:19:29 +00009; CHECK: t2ADDrs_lsl
10; CHECK: add.w r0, r0, r1, lsl #16
Anton Korobeynikov52237112009-06-17 18:13:58 +000011 %A = shl i32 %Y, 16
12 %B = add i32 %X, %A
13 ret i32 %B
14}
15
16define i32 @t2ADDrs_lsr(i32 %X, i32 %Y) {
Jim Grosbach9f07f3b2009-11-16 23:19:29 +000017; CHECK: t2ADDrs_lsr
18; CHECK: add.w r0, r0, r1, lsr #16
Anton Korobeynikov52237112009-06-17 18:13:58 +000019 %A = lshr i32 %Y, 16
20 %B = add i32 %X, %A
21 ret i32 %B
22}
23
24define i32 @t2ADDrs_asr(i32 %X, i32 %Y) {
Jim Grosbach9f07f3b2009-11-16 23:19:29 +000025; CHECK: t2ADDrs_asr
26; CHECK: add.w r0, r0, r1, asr #16
Anton Korobeynikov52237112009-06-17 18:13:58 +000027 %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))
33define i32 @t2ADDrs_ror(i32 %X, i32 %Y) {
Jim Grosbach9f07f3b2009-11-16 23:19:29 +000034; CHECK: t2ADDrs_ror
35; CHECK: add.w r0, r0, r1, ror #16
Anton Korobeynikov52237112009-06-17 18:13:58 +000036 %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
43define i32 @t2ADDrs_noRegShift(i32 %X, i32 %Y, i8 %sh) {
Jim Grosbach9f07f3b2009-11-16 23:19:29 +000044; CHECK: t2ADDrs_noRegShift
45; CHECK: uxtb r2, r2
46; CHECK: lsls r1, r2
47; CHECK: add r0, r1
Anton Korobeynikov52237112009-06-17 18:13:58 +000048 %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