diff options
author | Frits van Bommel <fvbommel@gmail.com> | 2010-11-29 20:36:52 +0000 |
---|---|---|
committer | Frits van Bommel <fvbommel@gmail.com> | 2010-11-29 20:36:52 +0000 |
commit | 3ee0af35842999c1781052fe74fdcb19997de950 (patch) | |
tree | f12d8cc7508c40d9fbd707d252b451b97ace43c6 /test/Transforms/ConstProp | |
parent | 53ca1f3190680f3e86aebe0f72f7918d63f71e0d (diff) |
Teach ConstantFoldInstruction() how to fold insertvalue and extractvalue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/ConstProp')
-rw-r--r-- | test/Transforms/ConstProp/extractvalue.ll | 68 | ||||
-rw-r--r-- | test/Transforms/ConstProp/insertvalue.ll | 68 |
2 files changed, 136 insertions, 0 deletions
diff --git a/test/Transforms/ConstProp/extractvalue.ll b/test/Transforms/ConstProp/extractvalue.ll new file mode 100644 index 0000000000..32d529181b --- /dev/null +++ b/test/Transforms/ConstProp/extractvalue.ll @@ -0,0 +1,68 @@ +; RUN: opt < %s -constprop -S | FileCheck %s + +%struct = type { i32, [4 x i8] } +%array = type [3 x %struct] + +define i32 @test1() { + %A = extractvalue %struct { i32 2, [4 x i8] c"foo\00" }, 0 + ret i32 %A +; CHECK: @test1 +; CHECK: ret i32 2 +} + +define i8 @test2() { + %A = extractvalue %struct { i32 2, [4 x i8] c"foo\00" }, 1, 2 + ret i8 %A +; CHECK: @test2 +; CHECK: ret i8 111 +} + +define i32 @test3() { + %A = extractvalue %array [ %struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" } ], 1, 0 + ret i32 %A +; CHECK: @test3 +; CHECK: ret i32 1 +} + +define i32 @zeroinitializer-test1() { + %A = extractvalue %struct zeroinitializer, 0 + ret i32 %A +; CHECK: @zeroinitializer-test1 +; CHECK: ret i32 0 +} + +define i8 @zeroinitializer-test2() { + %A = extractvalue %struct zeroinitializer, 1, 2 + ret i8 %A +; CHECK: @zeroinitializer-test2 +; CHECK: ret i8 0 +} + +define i32 @zeroinitializer-test3() { + %A = extractvalue %array zeroinitializer, 1, 0 + ret i32 %A +; CHECK: @zeroinitializer-test3 +; CHECK: ret i32 0 +} + +define i32 @undef-test1() { + %A = extractvalue %struct undef, 0 + ret i32 %A +; CHECK: @undef-test1 +; CHECK: ret i32 undef +} + +define i8 @undef-test2() { + %A = extractvalue %struct undef, 1, 2 + ret i8 %A +; CHECK: @undef-test2 +; CHECK: ret i8 undef +} + +define i32 @undef-test3() { + %A = extractvalue %array undef, 1, 0 + ret i32 %A +; CHECK: @undef-test3 +; CHECK: ret i32 undef +} + diff --git a/test/Transforms/ConstProp/insertvalue.ll b/test/Transforms/ConstProp/insertvalue.ll new file mode 100644 index 0000000000..f0eb553b21 --- /dev/null +++ b/test/Transforms/ConstProp/insertvalue.ll @@ -0,0 +1,68 @@ +; RUN: opt < %s -constprop -S | FileCheck %s + +%struct = type { i32, [4 x i8] } +%array = type [3 x %struct] + +define %struct @test1() { + %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i32 1, 0 + ret %struct %A +; CHECK: @test1 +; CHECK: ret %struct { i32 1, [4 x i8] c"foo\00" } +} + +define %struct @test2() { + %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i8 1, 1, 2 + ret %struct %A +; CHECK: @test2 +; CHECK: ret %struct { i32 2, [4 x i8] c"fo\01\00" } +} + +define %array @test3() { + %A = insertvalue %array [ %struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" } ], i32 -1, 1, 0 + ret %array %A +; CHECK: @test3 +; CHECK:ret %array [%struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 -1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" }] +} + +define %struct @zeroinitializer-test1() { + %A = insertvalue %struct zeroinitializer, i32 1, 0 + ret %struct %A +; CHECK: @zeroinitializer-test1 +; CHECK: ret %struct { i32 1, [4 x i8] zeroinitializer } +} + +define %struct @zeroinitializer-test2() { + %A = insertvalue %struct zeroinitializer, i8 1, 1, 2 + ret %struct %A +; CHECK: @zeroinitializer-test2 +; CHECK: ret %struct { i32 0, [4 x i8] c"\00\00\01\00" } +} + +define %array @zeroinitializer-test3() { + %A = insertvalue %array zeroinitializer, i32 1, 1, 0 + ret %array %A +; CHECK: @zeroinitializer-test3 +; CHECK: ret %array [%struct zeroinitializer, %struct { i32 1, [4 x i8] zeroinitializer }, %struct zeroinitializer] +} + +define %struct @undef-test1() { + %A = insertvalue %struct undef, i32 1, 0 + ret %struct %A +; CHECK: @undef-test1 +; CHECK: ret %struct { i32 1, [4 x i8] undef } +} + +define %struct @undef-test2() { + %A = insertvalue %struct undef, i8 0, 1, 2 + ret %struct %A +; CHECK: @undef-test2 +; CHECK: ret %struct { i32 undef, [4 x i8] [i8 undef, i8 undef, i8 0, i8 undef] } +} + +define %array @undef-test3() { + %A = insertvalue %array undef, i32 0, 1, 0 + ret %array %A +; CHECK: @undef-test3 +; CHECK: ret %array [%struct undef, %struct { i32 0, [4 x i8] undef }, %struct undef] +} + |