• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test that constant structs are folded.
2; RUN: opt %s -sccp -S | FileCheck %s
3
4define internal {i64} @struct1() {
5  %a = insertvalue {i64} undef, i64 24, 0
6  ret {i64} %a
7}
8
9; CHECK: define internal { i64 } @struct1() {
10; CHECK-NEXT:   ret { i64 } { i64 24 }
11; CHECK-NEXT: }
12
13define internal {i64, i64} @struct2() {
14  %a = insertvalue {i64, i64} undef, i64 24, 0
15  ret {i64, i64} %a
16}
17
18; CHECK: define internal { i64, i64 } @struct2() {
19; CHECK-NEXT:  ret { i64, i64 } { i64 24, i64 undef }
20; CHECK-NEXT: }
21
22define 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
27}
28
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
32; CHECK-NEXT: }
33
34; Test(s) for overdefined values.
35define internal {i64, i32} @struct4(i32 %x) {
36  %a = insertvalue {i64, i32} {i64 12, i32 24}, i32 %x, 1
37  ret {i64, i32} %a
38}
39
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
43; CHECK-NEXT: }
44
45define internal {i32} @struct5(i32 %x) {
46  %a = insertvalue {i32} undef, i32 %x, 0
47  ret {i32} %a
48}
49
50; CHECK: define internal { i32 } @struct5(i32 %x) {
51; CHECK-NEXT:  %a = insertvalue { i32 } undef, i32 %x, 0
52; CHECK-NEXT:  ret { i32 } %a
53; CHECK-NEXT: }
54
55
56define internal {i32} @struct6({i32} %x) {
57  %a = insertvalue {i32} %x, i32 12, 0
58  ret {i32} %a
59}
60
61; CHECK: define internal { i32 } @struct6({ i32 } %x) {
62; CHECK-NEXT:  ret { i32 } { i32 12 }
63; CHECK-NEXT: }
64
65define internal {i16} @struct7() {
66  %a = insertvalue {i16} {i16 4}, i16 7, 0
67  ret {i16} %a
68}
69
70; CHECK: define internal { i16 } @struct7() {
71; CHECK-NEXT:  ret { i16 } { i16 7 }
72; CHECK-NEXT: }
73