xref: /llvm-project/llvm/test/CodeGen/VE/Scalar/lea-opt.ll (revision b006b60dc993b2e0ba3e412c80709477241b6be6)
1; RUN: llc < %s -mtriple=ve | FileCheck %s
2; RUN: llc < %s -mtriple=ve -relocation-model=pic \
3; RUN:     | FileCheck %s --check-prefix=PIC
4
5;;; Tests for lea instruction and its optimizations
6
7%struct.buffer = type { i64, [1 x i8] }
8
9@data = internal global i8 0, align 1
10@buf = internal global %struct.buffer zeroinitializer, align 8
11
12; Function Attrs: norecurse nounwind readnone
13define nonnull ptr @lea_basic() {
14; CHECK-LABEL: lea_basic:
15; CHECK:       # %bb.0:
16; CHECK-NEXT:    lea %s0, data@lo
17; CHECK-NEXT:    and %s0, %s0, (32)0
18; CHECK-NEXT:    lea.sl %s0, data@hi(, %s0)
19; CHECK-NEXT:    b.l.t (, %s10)
20;
21; PIC-LABEL: lea_basic:
22; PIC:       # %bb.0:
23; PIC-NEXT:    st %s15, 24(, %s11)
24; PIC-NEXT:    st %s16, 32(, %s11)
25; PIC-NEXT:    lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24)
26; PIC-NEXT:    and %s15, %s15, (32)0
27; PIC-NEXT:    sic %s16
28; PIC-NEXT:    lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15)
29; PIC-NEXT:    lea %s0, data@gotoff_lo
30; PIC-NEXT:    and %s0, %s0, (32)0
31; PIC-NEXT:    lea.sl %s0, data@gotoff_hi(%s0, %s15)
32; PIC-NEXT:    ld %s16, 32(, %s11)
33; PIC-NEXT:    ld %s15, 24(, %s11)
34; PIC-NEXT:    b.l.t (, %s10)
35  ret ptr @data
36}
37
38; Function Attrs: norecurse nounwind readnone
39define ptr @lea_offset() {
40; CHECK-LABEL: lea_offset:
41; CHECK:       # %bb.0:
42; CHECK-NEXT:    lea %s0, buf@lo
43; CHECK-NEXT:    and %s0, %s0, (32)0
44; CHECK-NEXT:    lea.sl %s0, buf@hi(8, %s0)
45; CHECK-NEXT:    b.l.t (, %s10)
46;
47; PIC-LABEL: lea_offset:
48; PIC:       # %bb.0:
49; PIC-NEXT:    st %s15, 24(, %s11)
50; PIC-NEXT:    st %s16, 32(, %s11)
51; PIC-NEXT:    lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24)
52; PIC-NEXT:    and %s15, %s15, (32)0
53; PIC-NEXT:    sic %s16
54; PIC-NEXT:    lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15)
55; PIC-NEXT:    lea %s0, buf@gotoff_lo
56; PIC-NEXT:    and %s0, %s0, (32)0
57; PIC-NEXT:    lea.sl %s0, buf@gotoff_hi(, %s0)
58; PIC-NEXT:    lea %s0, 8(%s0, %s15)
59; PIC-NEXT:    ld %s16, 32(, %s11)
60; PIC-NEXT:    ld %s15, 24(, %s11)
61; PIC-NEXT:    b.l.t (, %s10)
62  ret ptr getelementptr inbounds (%struct.buffer, ptr @buf, i64 0, i32 1, i64 0)
63}
64