Jonathan Roelofs | 229eb4c | 2015-01-21 22:39:43 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=thumbv4t-none--eabi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-V4T |
| 2 | ; RUN: llc -mtriple=thumbv6m-none--eabi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-V6M |
| 3 | |
Renato Golin | b9887ef | 2015-02-25 14:41:06 +0000 | [diff] [blame] | 4 | ; CHECK-LABEL: test1 |
| 5 | define i32 @test1(i32* %p) { |
Jonathan Roelofs | 229eb4c | 2015-01-21 22:39:43 +0000 | [diff] [blame] | 6 | |
Renato Golin | b9887ef | 2015-02-25 14:41:06 +0000 | [diff] [blame] | 7 | ; Offsets less than 8 can be generated in a single add |
| 8 | ; CHECK: adds [[NEWBASE:r[0-9]]], r0, #4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 9 | %1 = getelementptr inbounds i32, i32* %p, i32 1 |
| 10 | %2 = getelementptr inbounds i32, i32* %p, i32 2 |
| 11 | %3 = getelementptr inbounds i32, i32* %p, i32 3 |
| 12 | %4 = getelementptr inbounds i32, i32* %p, i32 4 |
Jonathan Roelofs | 229eb4c | 2015-01-21 22:39:43 +0000 | [diff] [blame] | 13 | |
Jonathan Roelofs | 229eb4c | 2015-01-21 22:39:43 +0000 | [diff] [blame] | 14 | ; CHECK-NEXT: ldm [[NEWBASE]], |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 15 | %5 = load i32, i32* %1, align 4 |
| 16 | %6 = load i32, i32* %2, align 4 |
| 17 | %7 = load i32, i32* %3, align 4 |
| 18 | %8 = load i32, i32* %4, align 4 |
Renato Golin | b9887ef | 2015-02-25 14:41:06 +0000 | [diff] [blame] | 19 | |
| 20 | %9 = add nsw i32 %5, %6 |
| 21 | %10 = add nsw i32 %9, %7 |
| 22 | %11 = add nsw i32 %10, %8 |
| 23 | ret i32 %11 |
Jonathan Roelofs | 229eb4c | 2015-01-21 22:39:43 +0000 | [diff] [blame] | 24 | } |
| 25 | |
Renato Golin | b9887ef | 2015-02-25 14:41:06 +0000 | [diff] [blame] | 26 | ; CHECK-LABEL: test2 |
| 27 | define i32 @test2(i32* %p) { |
| 28 | |
| 29 | ; Offsets >=8 require a mov and an add |
| 30 | ; CHECK-V4T: movs [[NEWBASE:r[0-9]]], r0 |
| 31 | ; CHECK-V6M: mov [[NEWBASE:r[0-9]]], r0 |
| 32 | ; CHECK-NEXT: adds [[NEWBASE]], #8 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 33 | %1 = getelementptr inbounds i32, i32* %p, i32 2 |
| 34 | %2 = getelementptr inbounds i32, i32* %p, i32 3 |
| 35 | %3 = getelementptr inbounds i32, i32* %p, i32 4 |
| 36 | %4 = getelementptr inbounds i32, i32* %p, i32 5 |
Renato Golin | b9887ef | 2015-02-25 14:41:06 +0000 | [diff] [blame] | 37 | |
| 38 | ; CHECK-NEXT: ldm [[NEWBASE]], |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 39 | %5 = load i32, i32* %1, align 4 |
| 40 | %6 = load i32, i32* %2, align 4 |
| 41 | %7 = load i32, i32* %3, align 4 |
| 42 | %8 = load i32, i32* %4, align 4 |
Renato Golin | b9887ef | 2015-02-25 14:41:06 +0000 | [diff] [blame] | 43 | |
| 44 | %9 = add nsw i32 %5, %6 |
| 45 | %10 = add nsw i32 %9, %7 |
| 46 | %11 = add nsw i32 %10, %8 |
| 47 | ret i32 %11 |
| 48 | } |