1 ; RUN: llc < %s -mtriple=ve | FileCheck %s
2 ; RUN: llc < %s -mtriple=ve -relocation-model=pic \
3 ; RUN: | FileCheck %s --check-prefix=PIC
5 ;;; Tests for lea instruction and its optimizations
7 %struct.buffer = type { i64, [1 x i8] }
9 @data = internal global i8 0, align 1
10 @buf = internal global %struct.buffer zeroinitializer, align 8
12 ; Function Attrs: norecurse nounwind readnone
13 define nonnull ptr @lea_basic() {
14 ; CHECK-LABEL: lea_basic:
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)
21 ; PIC-LABEL: lea_basic:
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
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)
38 ; Function Attrs: norecurse nounwind readnone
39 define ptr @lea_offset() {
40 ; CHECK-LABEL: lea_offset:
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)
47 ; PIC-LABEL: lea_offset:
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
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)