blob: 33adcdc3c4645edcd4a5d1d51e4b006f2326d005 [file] [log] [blame]
Mehdi Amini945a6602015-02-27 18:32:11 +00001; RUN: llc -mtriple=aarch64-apple-darwin -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s | FileCheck %s
Juergen Ributzkaf82c9872014-10-15 18:58:07 +00002
3%struct.foo = type { i32, i64, float, double }
4
5define double* @test_struct(%struct.foo* %f) {
6; CHECK-LABEL: test_struct
7; CHECK: add x0, x0, #24
David Blaikie79e6c742015-02-27 19:29:02 +00008 %1 = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 0, i32 3
Juergen Ributzkaf82c9872014-10-15 18:58:07 +00009 ret double* %1
10}
11
12define 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 Blaikie79e6c742015-02-27 19:29:02 +000016 %1 = getelementptr inbounds i32, i32* %a, i64 %i
Juergen Ributzkaf82c9872014-10-15 18:58:07 +000017 ret i32* %1
18}
19
20define i32* @test_array2(i32* %a) {
21; CHECK-LABEL: test_array2
22; CHECK: add x0, x0, #16
David Blaikie79e6c742015-02-27 19:29:02 +000023 %1 = getelementptr inbounds i32, i32* %a, i64 4
Juergen Ributzkaf82c9872014-10-15 18:58:07 +000024 ret i32* %1
25}
26
27define i32* @test_array3(i32* %a) {
28; CHECK-LABEL: test_array3
29; CHECK: add x0, x0, #1, lsl #12
David Blaikie79e6c742015-02-27 19:29:02 +000030 %1 = getelementptr inbounds i32, i32* %a, i64 1024
Juergen Ributzkaf82c9872014-10-15 18:58:07 +000031 ret i32* %1
32}
33
34define 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 Blaikie79e6c742015-02-27 19:29:02 +000038 %1 = getelementptr inbounds i32, i32* %a, i64 1026
Juergen Ributzkaf82c9872014-10-15 18:58:07 +000039 ret i32* %1
40}
41
Juergen Ributzka0af310d2014-11-13 20:50:44 +000042define 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 Blaikie79e6c742015-02-27 19:29:02 +000047 %1 = getelementptr inbounds i32, i32* %a, i32 %i
Juergen Ributzka0af310d2014-11-13 20:50:44 +000048 ret i32* %1
49}