summaryrefslogtreecommitdiff
path: root/test/CodeGen/PowerPC
diff options
context:
space:
mode:
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>2013-08-30 02:29:45 +0000
committerBill Schmidt <wschmidt@linux.vnet.ibm.com>2013-08-30 02:29:45 +0000
commit7248968fa529726b44d41bd25403d50c74db4bc4 (patch)
treec5982d93a8af273fdbe4e2712de1e43d2e94b4af /test/CodeGen/PowerPC
parent6dc6a89d73c24f20caabda4cdcd9279e88658d0b (diff)
downloadllvm-7248968fa529726b44d41bd25403d50c74db4bc4.tar.gz
llvm-7248968fa529726b44d41bd25403d50c74db4bc4.tar.bz2
llvm-7248968fa529726b44d41bd25403d50c74db4bc4.tar.xz
[PowerPC] Add loads, stores, and related things to fast-isel.
This is the next big chunk of fast-isel code. The primary purpose is to implement selection of loads and stores, but there is a lot of drag-along to support this. The common code to analyze addresses for both loads and stores is substantial. It's also necessary to add the materialization code for global values. Related to load-store processing is the code to fold loads into integer extends, since otherwise we generate lots of redundant instructions. We also need to add some overrides to some FastEmit routines to ensure we don't assign GPR 0 to a virtual register when this would change the meaning of an instruction. I added handling selection of a few binary arithmetic instructions, to enable committing some test cases I wrote a while back. Finally, ap couple of miscellaneous changes: * I cleaned up some poor style from a previous patch in PPCISelLowering.cpp, pointed out by David Blaikie. * I enlarged the Addr.Offset field to avoid sign problems with 32-bit offsets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189636 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/PowerPC')
-rw-r--r--test/CodeGen/PowerPC/fast-isel-binary.ll137
-rw-r--r--test/CodeGen/PowerPC/fast-isel-fold.ll95
-rw-r--r--test/CodeGen/PowerPC/fast-isel-load-store.ll202
3 files changed, 434 insertions, 0 deletions
diff --git a/test/CodeGen/PowerPC/fast-isel-binary.ll b/test/CodeGen/PowerPC/fast-isel-binary.ll
new file mode 100644
index 0000000000..43a6cd0850
--- /dev/null
+++ b/test/CodeGen/PowerPC/fast-isel-binary.ll
@@ -0,0 +1,137 @@
+; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s --check-prefix=ELF64
+
+; Test add with non-legal types
+
+define void @add_i8(i8 %a, i8 %b) nounwind ssp {
+entry:
+; ELF64: add_i8
+ %a.addr = alloca i8, align 4
+ %0 = add i8 %a, %b
+; ELF64: add
+ store i8 %0, i8* %a.addr, align 4
+ ret void
+}
+
+define void @add_i8_imm(i8 %a) nounwind ssp {
+entry:
+; ELF64: add_i8_imm
+ %a.addr = alloca i8, align 4
+ %0 = add i8 %a, 22;
+; ELF64: addi
+ store i8 %0, i8* %a.addr, align 4
+ ret void
+}
+
+define void @add_i16(i16 %a, i16 %b) nounwind ssp {
+entry:
+; ELF64: add_i16
+ %a.addr = alloca i16, align 4
+ %0 = add i16 %a, %b
+; ELF64: add
+ store i16 %0, i16* %a.addr, align 4
+ ret void
+}
+
+define void @add_i16_imm(i16 %a, i16 %b) nounwind ssp {
+entry:
+; ELF64: add_i16_imm
+ %a.addr = alloca i16, align 4
+ %0 = add i16 %a, 243;
+; ELF64: addi
+ store i16 %0, i16* %a.addr, align 4
+ ret void
+}
+
+; Test or with non-legal types
+
+define void @or_i8(i8 %a, i8 %b) nounwind ssp {
+entry:
+; ELF64: or_i8
+ %a.addr = alloca i8, align 4
+ %0 = or i8 %a, %b
+; ELF64: or
+ store i8 %0, i8* %a.addr, align 4
+ ret void
+}
+
+define void @or_i8_imm(i8 %a) nounwind ssp {
+entry:
+; ELF64: or_i8_imm
+ %a.addr = alloca i8, align 4
+ %0 = or i8 %a, -13;
+; ELF64: ori
+ store i8 %0, i8* %a.addr, align 4
+ ret void
+}
+
+define void @or_i16(i16 %a, i16 %b) nounwind ssp {
+entry:
+; ELF64: or_i16
+ %a.addr = alloca i16, align 4
+ %0 = or i16 %a, %b
+; ELF64: or
+ store i16 %0, i16* %a.addr, align 4
+ ret void
+}
+
+define void @or_i16_imm(i16 %a) nounwind ssp {
+entry:
+; ELF64: or_i16_imm
+ %a.addr = alloca i16, align 4
+ %0 = or i16 %a, 273;
+; ELF64: ori
+ store i16 %0, i16* %a.addr, align 4
+ ret void
+}
+
+; Test sub with non-legal types
+
+define void @sub_i8(i8 %a, i8 %b) nounwind ssp {
+entry:
+; ELF64: sub_i8
+ %a.addr = alloca i8, align 4
+ %0 = sub i8 %a, %b
+; ELF64: subf
+ store i8 %0, i8* %a.addr, align 4
+ ret void
+}
+
+define void @sub_i8_imm(i8 %a) nounwind ssp {
+entry:
+; ELF64: sub_i8_imm
+ %a.addr = alloca i8, align 4
+ %0 = sub i8 %a, 22;
+; ELF64: addi
+ store i8 %0, i8* %a.addr, align 4
+ ret void
+}
+
+define void @sub_i16(i16 %a, i16 %b) nounwind ssp {
+entry:
+; ELF64: sub_i16
+ %a.addr = alloca i16, align 4
+ %0 = sub i16 %a, %b
+; ELF64: subf
+ store i16 %0, i16* %a.addr, align 4
+ ret void
+}
+
+define void @sub_i16_imm(i16 %a) nounwind ssp {
+entry:
+; ELF64: sub_i16_imm
+ %a.addr = alloca i16, align 4
+ %0 = sub i16 %a, 247;
+; ELF64: addi
+ store i16 %0, i16* %a.addr, align 4
+ ret void
+}
+
+define void @sub_i16_badimm(i16 %a) nounwind ssp {
+entry:
+; ELF64: sub_i16_imm
+ %a.addr = alloca i16, align 4
+ %0 = sub i16 %a, -32768;
+; ELF64: subf
+ store i16 %0, i16* %a.addr, align 4
+ ret void
+}
diff --git a/test/CodeGen/PowerPC/fast-isel-fold.ll b/test/CodeGen/PowerPC/fast-isel-fold.ll
new file mode 100644
index 0000000000..21e691224d
--- /dev/null
+++ b/test/CodeGen/PowerPC/fast-isel-fold.ll
@@ -0,0 +1,95 @@
+; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s --check-prefix=ELF64
+
+@a = global i8 1, align 1
+@b = global i16 2, align 2
+@c = global i32 4, align 4
+
+define i32 @t3() nounwind uwtable ssp {
+; ELF64: t3
+ %1 = load i8* @a, align 1
+ %2 = zext i8 %1 to i32
+; ELF64: lbz
+; ELF64-NOT: rlwinm
+ ret i32 %2
+}
+
+define i32 @t4() nounwind uwtable ssp {
+; ELF64: t4
+ %1 = load i16* @b, align 2
+ %2 = zext i16 %1 to i32
+; ELF64: lhz
+; ELF64-NOT: rlwinm
+ ret i32 %2
+}
+
+define i32 @t5() nounwind uwtable ssp {
+; ELF64: t5
+ %1 = load i16* @b, align 2
+ %2 = sext i16 %1 to i32
+; ELF64: lha
+; ELF64-NOT: rlwinm
+ ret i32 %2
+}
+
+define i32 @t6() nounwind uwtable ssp {
+; ELF64: t6
+ %1 = load i8* @a, align 2
+ %2 = sext i8 %1 to i32
+; ELF64: lbz
+; ELF64-NOT: rlwinm
+ ret i32 %2
+}
+
+define i64 @t7() nounwind uwtable ssp {
+; ELF64: t7
+ %1 = load i8* @a, align 1
+ %2 = zext i8 %1 to i64
+; ELF64: lbz
+; ELF64-NOT: rldicl
+ ret i64 %2
+}
+
+define i64 @t8() nounwind uwtable ssp {
+; ELF64: t8
+ %1 = load i16* @b, align 2
+ %2 = zext i16 %1 to i64
+; ELF64: lhz
+; ELF64-NOT: rldicl
+ ret i64 %2
+}
+
+define i64 @t9() nounwind uwtable ssp {
+; ELF64: t9
+ %1 = load i16* @b, align 2
+ %2 = sext i16 %1 to i64
+; ELF64: lha
+; ELF64-NOT: extsh
+ ret i64 %2
+}
+
+define i64 @t10() nounwind uwtable ssp {
+; ELF64: t10
+ %1 = load i8* @a, align 2
+ %2 = sext i8 %1 to i64
+; ELF64: lbz
+; ELF64: extsb
+ ret i64 %2
+}
+
+define i64 @t11() nounwind uwtable ssp {
+; ELF64: t11
+ %1 = load i32* @c, align 4
+ %2 = zext i32 %1 to i64
+; ELF64: lwz
+; ELF64-NOT: rldicl
+ ret i64 %2
+}
+
+define i64 @t12() nounwind uwtable ssp {
+; ELF64: t12
+ %1 = load i32* @c, align 4
+ %2 = sext i32 %1 to i64
+; ELF64: lwa
+; ELF64-NOT: extsw
+ ret i64 %2
+}
diff --git a/test/CodeGen/PowerPC/fast-isel-load-store.ll b/test/CodeGen/PowerPC/fast-isel-load-store.ll
new file mode 100644
index 0000000000..026b15fe5e
--- /dev/null
+++ b/test/CodeGen/PowerPC/fast-isel-load-store.ll
@@ -0,0 +1,202 @@
+; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s --check-prefix=ELF64
+
+; This test verifies that load/store instructions are properly generated,
+; and that they pass MI verification.
+
+@a = global i8 1, align 1
+@b = global i16 2, align 2
+@c = global i32 4, align 4
+@d = global i64 8, align 8
+@e = global float 1.25, align 4
+@f = global double 3.5, align 8
+
+%struct.s = type<{ i8, i32 }>
+%struct.t = type<{ i8, i64 }>
+
+@g = global %struct.s <{ i8 1, i32 2 }>, align 1
+@h = global %struct.t <{ i8 1, i64 2 }>, align 1
+
+@i = common global [8192 x i64] zeroinitializer, align 8
+
+; load
+
+define i8 @t1() nounwind uwtable ssp {
+; ELF64: t1
+ %1 = load i8* @a, align 1
+; ELF64: lbz
+ %2 = add nsw i8 %1, 1
+; ELF64: addi
+ ret i8 %2
+}
+
+define i16 @t2() nounwind uwtable ssp {
+; ELF64: t2
+ %1 = load i16* @b, align 2
+; ELF64: lhz
+ %2 = add nsw i16 %1, 1
+; ELF64: addi
+ ret i16 %2
+}
+
+define i32 @t3() nounwind uwtable ssp {
+; ELF64: t3
+ %1 = load i32* @c, align 4
+; ELF64: lwz
+ %2 = add nsw i32 %1, 1
+; ELF64: addi
+ ret i32 %2
+}
+
+define i64 @t4() nounwind uwtable ssp {
+; ELF64: t4
+ %1 = load i64* @d, align 4
+; ELF64: ld
+ %2 = add nsw i64 %1, 1
+; ELF64: addi
+ ret i64 %2
+}
+
+define float @t5() nounwind uwtable ssp {
+; ELF64: t5
+ %1 = load float* @e, align 4
+; ELF64: lfs
+ %2 = fadd float %1, 1.0
+; ELF64: fadds
+ ret float %2
+}
+
+define double @t6() nounwind uwtable ssp {
+; ELF64: t6
+ %1 = load double* @f, align 8
+; ELF64: lfd
+ %2 = fadd double %1, 1.0
+; ELF64: fadd
+ ret double %2
+}
+
+; store
+
+define void @t7(i8 %v) nounwind uwtable ssp {
+; ELF64: t7
+ %1 = add nsw i8 %v, 1
+ store i8 %1, i8* @a, align 1
+; ELF64: addis
+; ELF64: addi
+; ELF64: addi
+; ELF64: stb
+ ret void
+}
+
+define void @t8(i16 %v) nounwind uwtable ssp {
+; ELF64: t8
+ %1 = add nsw i16 %v, 1
+ store i16 %1, i16* @b, align 2
+; ELF64: addis
+; ELF64: addi
+; ELF64: addi
+; ELF64: sth
+ ret void
+}
+
+define void @t9(i32 %v) nounwind uwtable ssp {
+; ELF64: t9
+ %1 = add nsw i32 %v, 1
+ store i32 %1, i32* @c, align 4
+; ELF64: addis
+; ELF64: addi
+; ELF64: addi
+; ELF64: stw
+ ret void
+}
+
+define void @t10(i64 %v) nounwind uwtable ssp {
+; ELF64: t10
+ %1 = add nsw i64 %v, 1
+ store i64 %1, i64* @d, align 4
+; ELF64: addis
+; ELF64: addi
+; ELF64: addi
+; ELF64: std
+ ret void
+}
+
+define void @t11(float %v) nounwind uwtable ssp {
+; ELF64: t11
+ %1 = fadd float %v, 1.0
+ store float %1, float* @e, align 4
+; ELF64: fadds
+; ELF64: stfs
+ ret void
+}
+
+define void @t12(double %v) nounwind uwtable ssp {
+; ELF64: t12
+ %1 = fadd double %v, 1.0
+ store double %1, double* @f, align 8
+; ELF64: fadd
+; ELF64: stfd
+ ret void
+}
+
+;; lwa requires an offset divisible by 4, so we need lwax here.
+define i64 @t13() nounwind uwtable ssp {
+; ELF64: t13
+ %1 = load i32* getelementptr inbounds (%struct.s* @g, i32 0, i32 1), align 1
+ %2 = sext i32 %1 to i64
+; ELF64: li
+; ELF64: lwax
+ %3 = add nsw i64 %2, 1
+; ELF64: addi
+ ret i64 %3
+}
+
+;; ld requires an offset divisible by 4, so we need ldx here.
+define i64 @t14() nounwind uwtable ssp {
+; ELF64: t14
+ %1 = load i64* getelementptr inbounds (%struct.t* @h, i32 0, i32 1), align 1
+; ELF64: li
+; ELF64: ldx
+ %2 = add nsw i64 %1, 1
+; ELF64: addi
+ ret i64 %2
+}
+
+;; std requires an offset divisible by 4, so we need stdx here.
+define void @t15(i64 %v) nounwind uwtable ssp {
+; ELF64: t15
+ %1 = add nsw i64 %v, 1
+ store i64 %1, i64* getelementptr inbounds (%struct.t* @h, i32 0, i32 1), align 1
+; ELF64: addis
+; ELF64: addi
+; ELF64: addi
+; ELF64: li
+; ELF64: stdx
+ ret void
+}
+
+;; ld requires an offset that fits in 16 bits, so we need ldx here.
+define i64 @t16() nounwind uwtable ssp {
+; ELF64: t16
+ %1 = load i64* getelementptr inbounds ([8192 x i64]* @i, i32 0, i64 5000), align 8
+; ELF64: lis
+; ELF64: ori
+; ELF64: ldx
+ %2 = add nsw i64 %1, 1
+; ELF64: addi
+ ret i64 %2
+}
+
+;; std requires an offset that fits in 16 bits, so we need stdx here.
+define void @t17(i64 %v) nounwind uwtable ssp {
+; ELF64: t17
+ %1 = add nsw i64 %v, 1
+ store i64 %1, i64* getelementptr inbounds ([8192 x i64]* @i, i32 0, i64 5000), align 8
+; ELF64: addis
+; ELF64: ld
+; ELF64: addi
+; ELF64: lis
+; ELF64: ori
+; ELF64: stdx
+ ret void
+}
+