1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Test selection of addresses with indices in cases where the address
5 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
7 ; A simple index address.
8 define void @f1(i64 %addr, i64 %index) {
11 ; CHECK-NEXT: lb %r0, 0(%r3,%r2)
13 %add = add i64 %addr, %index
14 %ptr = inttoptr i64 %add to i8 *
15 %a = load volatile i8, i8 *%ptr
19 ; An address with an index and a displacement (order 1).
20 define void @f2(i64 %addr, i64 %index) {
23 ; CHECK-NEXT: lb %r0, 100(%r3,%r2)
25 %add1 = add i64 %addr, %index
26 %add2 = add i64 %add1, 100
27 %ptr = inttoptr i64 %add2 to i8 *
28 %a = load volatile i8, i8 *%ptr
32 ; An address with an index and a displacement (order 2).
33 define void @f3(i64 %addr, i64 %index) {
36 ; CHECK-NEXT: lb %r0, 100(%r3,%r2)
38 %add1 = add i64 %addr, 100
39 %add2 = add i64 %add1, %index
40 %ptr = inttoptr i64 %add2 to i8 *
41 %a = load volatile i8, i8 *%ptr
45 ; An address with an index and a subtracted displacement (order 1).
46 define void @f4(i64 %addr, i64 %index) {
49 ; CHECK-NEXT: lb %r0, -100(%r3,%r2)
51 %add1 = add i64 %addr, %index
52 %add2 = sub i64 %add1, 100
53 %ptr = inttoptr i64 %add2 to i8 *
54 %a = load volatile i8, i8 *%ptr
58 ; An address with an index and a subtracted displacement (order 2).
59 define void @f5(i64 %addr, i64 %index) {
62 ; CHECK-NEXT: lb %r0, -100(%r3,%r2)
64 %add1 = sub i64 %addr, 100
65 %add2 = add i64 %add1, %index
66 %ptr = inttoptr i64 %add2 to i8 *
67 %a = load volatile i8, i8 *%ptr
71 ; An address with an index and a displacement added using OR.
72 define void @f6(i64 %addr, i64 %index) {
75 ; CHECK-NEXT: nill %r2, 65528
76 ; CHECK-NEXT: lb %r0, 6(%r2,%r3)
78 %aligned = and i64 %addr, -8
79 %or = or i64 %aligned, 6
80 %add = add i64 %or, %index
81 %ptr = inttoptr i64 %add to i8 *
82 %a = load volatile i8, i8 *%ptr
86 ; Like f6, but without the masking. This OR doesn't count as a displacement.
87 define void @f7(i64 %addr, i64 %index) {
90 ; CHECK-NEXT: oill %r2, 6
91 ; CHECK-NEXT: lb %r0, 0(%r3,%r2)
94 %add = add i64 %or, %index
95 %ptr = inttoptr i64 %add to i8 *
96 %a = load volatile i8, i8 *%ptr
100 ; Like f6, but with the OR applied after the index. We don't know anything
101 ; about the alignment of %add here.
102 define void @f8(i64 %addr, i64 %index) {
105 ; CHECK-NEXT: nill %r2, 65528
106 ; CHECK-NEXT: agr %r2, %r3
107 ; CHECK-NEXT: oill %r2, 6
108 ; CHECK-NEXT: lb %r0, 0(%r2)
109 ; CHECK-NEXT: br %r14
110 %aligned = and i64 %addr, -8
111 %add = add i64 %aligned, %index
113 %ptr = inttoptr i64 %or to i8 *
114 %a = load volatile i8, i8 *%ptr