summaryrefslogtreecommitdiff
path: root/test/CodeGen/PowerPC
diff options
context:
space:
mode:
authorGuozhi Wei <carrot@google.com>2017-11-16 18:27:34 +0000
committerGuozhi Wei <carrot@google.com>2017-11-16 18:27:34 +0000
commita448ad72b2ae819fed262df2d5dd0d794a81af2e (patch)
treed155351ae8273123fef898a89347e1271d037db3 /test/CodeGen/PowerPC
parentbb4ea6522c44e375d75e3c8680eae0ae2d2ff1cf (diff)
[PPC] Change i32 constant in store instruction to i64
This patch changes all i32 constant in store instruction to i64 with truncation, to increase the chance that the referenced constant can be shared with other i64 constant. Differential Revision: https://reviews.llvm.org/D39352 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/PowerPC')
-rw-r--r--test/CodeGen/PowerPC/store-constant.ll44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/CodeGen/PowerPC/store-constant.ll b/test/CodeGen/PowerPC/store-constant.ll
new file mode 100644
index 00000000000..d17d1ba471f
--- /dev/null
+++ b/test/CodeGen/PowerPC/store-constant.ll
@@ -0,0 +1,44 @@
+; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 -verify-machineinstrs | FileCheck %s
+
+; Test the same constant can be used by different stores.
+
+%struct.S = type { i64, i8, i16, i32 }
+
+define void @foo(%struct.S* %p) {
+ %l4 = bitcast %struct.S* %p to i64*
+ store i64 0, i64* %l4, align 8
+ %c = getelementptr %struct.S, %struct.S* %p, i64 0, i32 1
+ store i8 0, i8* %c, align 8
+ %s = getelementptr %struct.S, %struct.S* %p, i64 0, i32 2
+ store i16 0, i16* %s, align 2
+ %i = getelementptr %struct.S, %struct.S* %p, i64 0, i32 3
+ store i32 0, i32* %i, align 4
+ ret void
+
+; CHECK-LABEL: @foo
+; CHECK: li 4, 0
+; CHECK: stb 4, 8(3)
+; CHECK: std 4, 0(3)
+; CHECK: sth 4, 10(3)
+; CHECK: stw 4, 12(3)
+}
+
+define void @bar(%struct.S* %p) {
+ %i = getelementptr %struct.S, %struct.S* %p, i64 0, i32 3
+ store i32 2, i32* %i, align 4
+ %s = getelementptr %struct.S, %struct.S* %p, i64 0, i32 2
+ store i16 2, i16* %s, align 2
+ %c = getelementptr %struct.S, %struct.S* %p, i64 0, i32 1
+ store i8 2, i8* %c, align 8
+ %l4 = bitcast %struct.S* %p to i64*
+ store i64 2, i64* %l4, align 8
+ ret void
+
+; CHECK-LABEL: @bar
+; CHECK: li 4, 2
+; CHECK: stw 4, 12(3)
+; CHECK: sth 4, 10(3)
+; CHECK: std 4, 0(3)
+; CHECK: stb 4, 8(3)
+}
+