1 ; Test that constant structs are folded.
2 ; RUN: opt %s -sccp -S | FileCheck %s
4 define internal {i64} @struct1() {
5 %a = insertvalue {i64} undef, i64 24, 0
9 ; CHECK: define internal { i64 } @struct1() {
10 ; CHECK-NEXT: ret { i64 } { i64 24 }
13 define internal {i64, i64} @struct2() {
14 %a = insertvalue {i64, i64} undef, i64 24, 0
18 ; CHECK: define internal { i64, i64 } @struct2() {
19 ; CHECK-NEXT: ret { i64, i64 } { i64 24, i64 undef }
22 define internal {i64, i64, i64} @struct3(i64 %x) {
23 %a = insertvalue {i64, i64, i64} undef, i64 24, 0
24 %b = insertvalue {i64, i64, i64} %a, i64 36, 1
25 %c = insertvalue {i64, i64, i64} %b, i64 %x, 2
26 ret {i64, i64, i64} %c
29 ; CHECK: define internal { i64, i64, i64 } @struct3(i64 %x) {
30 ; CHECK-NEXT: %c = insertvalue { i64, i64, i64 } { i64 24, i64 36, i64 undef }, i64 %x, 2
31 ; CHECK-NEXT: ret { i64, i64, i64 } %c
34 ; Test(s) for overdefined values.
35 define internal {i64, i32} @struct4(i32 %x) {
36 %a = insertvalue {i64, i32} {i64 12, i32 24}, i32 %x, 1
40 ; CHECK: define internal { i64, i32 } @struct4(i32 %x) {
41 ; CHECK-NEXT: %a = insertvalue { i64, i32 } { i64 12, i32 24 }, i32 %x, 1
42 ; CHECK-NEXT: ret { i64, i32 } %a
45 define internal {i32} @struct5(i32 %x) {
46 %a = insertvalue {i32} undef, i32 %x, 0
50 ; CHECK: define internal { i32 } @struct5(i32 %x) {
51 ; CHECK-NEXT: %a = insertvalue { i32 } undef, i32 %x, 0
52 ; CHECK-NEXT: ret { i32 } %a
56 define internal {i32} @struct6({i32} %x) {
57 %a = insertvalue {i32} %x, i32 12, 0
61 ; CHECK: define internal { i32 } @struct6({ i32 } %x) {
62 ; CHECK-NEXT: ret { i32 } { i32 12 }
65 define internal {i16} @struct7() {
66 %a = insertvalue {i16} {i16 4}, i16 7, 0
70 ; CHECK: define internal { i16 } @struct7() {
71 ; CHECK-NEXT: ret { i16 } { i16 7 }