1 ; Test selection of addresses with indices in cases where the address
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 ; A simple index address.
7 define void @f1(i64 %addr, i64 %index) {
9 ; CHECK: lb %r0, 0(%r3,%r2)
11 %add = add i64 %addr, %index
12 %ptr = inttoptr i64 %add to i8 *
13 %a = load volatile i8, i8 *%ptr
17 ; An address with an index and a displacement (order 1).
18 define void @f2(i64 %addr, i64 %index) {
20 ; CHECK: lb %r0, 100(%r3,%r2)
22 %add1 = add i64 %addr, %index
23 %add2 = add i64 %add1, 100
24 %ptr = inttoptr i64 %add2 to i8 *
25 %a = load volatile i8, i8 *%ptr
29 ; An address with an index and a displacement (order 2).
30 define void @f3(i64 %addr, i64 %index) {
32 ; CHECK: lb %r0, 100(%r3,%r2)
34 %add1 = add i64 %addr, 100
35 %add2 = add i64 %add1, %index
36 %ptr = inttoptr i64 %add2 to i8 *
37 %a = load volatile i8, i8 *%ptr
41 ; An address with an index and a subtracted displacement (order 1).
42 define void @f4(i64 %addr, i64 %index) {
44 ; CHECK: lb %r0, -100(%r3,%r2)
46 %add1 = add i64 %addr, %index
47 %add2 = sub i64 %add1, 100
48 %ptr = inttoptr i64 %add2 to i8 *
49 %a = load volatile i8, i8 *%ptr
53 ; An address with an index and a subtracted displacement (order 2).
54 define void @f5(i64 %addr, i64 %index) {
56 ; CHECK: lb %r0, -100(%r3,%r2)
58 %add1 = sub i64 %addr, 100
59 %add2 = add i64 %add1, %index
60 %ptr = inttoptr i64 %add2 to i8 *
61 %a = load volatile i8, i8 *%ptr
65 ; An address with an index and a displacement added using OR.
66 define void @f6(i64 %addr, i64 %index) {
68 ; CHECK: nill %r2, 65528
69 ; CHECK: lb %r0, 6(%r3,%r2)
71 %aligned = and i64 %addr, -8
72 %or = or i64 %aligned, 6
73 %add = add i64 %or, %index
74 %ptr = inttoptr i64 %add to i8 *
75 %a = load volatile i8, i8 *%ptr
79 ; Like f6, but without the masking. This OR doesn't count as a displacement.
80 define void @f7(i64 %addr, i64 %index) {
83 ; CHECK: lb %r0, 0(%r3,%r2)
86 %add = add i64 %or, %index
87 %ptr = inttoptr i64 %add to i8 *
88 %a = load volatile i8, i8 *%ptr
92 ; Like f6, but with the OR applied after the index. We don't know anything
93 ; about the alignment of %add here.
94 define void @f8(i64 %addr, i64 %index) {
96 ; CHECK: nill %r2, 65528
99 ; CHECK: lb %r0, 0(%r2)
101 %aligned = and i64 %addr, -8
102 %add = add i64 %aligned, %index
104 %ptr = inttoptr i64 %or to i8 *
105 %a = load volatile i8, i8 *%ptr