Mehdi Amini | 945a660 | 2015-02-27 18:32:11 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=aarch64-apple-darwin -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s | FileCheck %s |
Juergen Ributzka | f82c987 | 2014-10-15 18:58:07 +0000 | [diff] [blame] | 2 | |
| 3 | %struct.foo = type { i32, i64, float, double } |
| 4 | |
| 5 | define double* @test_struct(%struct.foo* %f) { |
| 6 | ; CHECK-LABEL: test_struct |
| 7 | ; CHECK: add x0, x0, #24 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 8 | %1 = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 0, i32 3 |
Juergen Ributzka | f82c987 | 2014-10-15 18:58:07 +0000 | [diff] [blame] | 9 | ret double* %1 |
| 10 | } |
| 11 | |
| 12 | define i32* @test_array1(i32* %a, i64 %i) { |
| 13 | ; CHECK-LABEL: test_array1 |
| 14 | ; CHECK: orr [[REG:x[0-9]+]], xzr, #0x4 |
| 15 | ; CHECK-NEXT: madd x0, x1, [[REG]], x0 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 16 | %1 = getelementptr inbounds i32, i32* %a, i64 %i |
Juergen Ributzka | f82c987 | 2014-10-15 18:58:07 +0000 | [diff] [blame] | 17 | ret i32* %1 |
| 18 | } |
| 19 | |
| 20 | define i32* @test_array2(i32* %a) { |
| 21 | ; CHECK-LABEL: test_array2 |
| 22 | ; CHECK: add x0, x0, #16 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 23 | %1 = getelementptr inbounds i32, i32* %a, i64 4 |
Juergen Ributzka | f82c987 | 2014-10-15 18:58:07 +0000 | [diff] [blame] | 24 | ret i32* %1 |
| 25 | } |
| 26 | |
| 27 | define i32* @test_array3(i32* %a) { |
| 28 | ; CHECK-LABEL: test_array3 |
| 29 | ; CHECK: add x0, x0, #1, lsl #12 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 30 | %1 = getelementptr inbounds i32, i32* %a, i64 1024 |
Juergen Ributzka | f82c987 | 2014-10-15 18:58:07 +0000 | [diff] [blame] | 31 | ret i32* %1 |
| 32 | } |
| 33 | |
| 34 | define i32* @test_array4(i32* %a) { |
| 35 | ; CHECK-LABEL: test_array4 |
| 36 | ; CHECK: movz [[REG:x[0-9]+]], #0x1008 |
| 37 | ; CHECK-NEXR: add x0, x0, [[REG]] |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 38 | %1 = getelementptr inbounds i32, i32* %a, i64 1026 |
Juergen Ributzka | f82c987 | 2014-10-15 18:58:07 +0000 | [diff] [blame] | 39 | ret i32* %1 |
| 40 | } |
| 41 | |
Juergen Ributzka | 0af310d | 2014-11-13 20:50:44 +0000 | [diff] [blame] | 42 | define i32* @test_array5(i32* %a, i32 %i) { |
| 43 | ; CHECK-LABEL: test_array5 |
| 44 | ; CHECK: sxtw [[REG1:x[0-9]+]], w1 |
| 45 | ; CHECK-NEXT: orr [[REG2:x[0-9]+]], xzr, #0x4 |
| 46 | ; CHECK-NEXT: madd {{x[0-9]+}}, [[REG1]], [[REG2]], x0 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 47 | %1 = getelementptr inbounds i32, i32* %a, i32 %i |
Juergen Ributzka | 0af310d | 2014-11-13 20:50:44 +0000 | [diff] [blame] | 48 | ret i32* %1 |
| 49 | } |