; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
; Test that constant structs are folded.
; RUN: opt %s -passes=sccp -S | FileCheck %s
define internal {i64} @struct1() {
; CHECK-LABEL: define internal { i64 } @struct1() {
; CHECK-NEXT: ret { i64 } { i64 24 }
;
%a = insertvalue {i64} undef, i64 24, 0
ret {i64} %a
}
define internal {i64, i64} @struct2() {
; CHECK-LABEL: define internal { i64, i64 } @struct2() {
; CHECK-NEXT: ret { i64, i64 } { i64 24, i64 undef }
;
%a = insertvalue {i64, i64} undef, i64 24, 0
ret {i64, i64} %a
}
define internal {i64, i64, i64} @struct3(i64 %x) {
; CHECK-LABEL: define internal { i64, i64, i64 } @struct3
; CHECK-SAME: (i64 [[X:%.*]]) {
; CHECK-NEXT: [[C:%.*]] = insertvalue { i64, i64, i64 } { i64 24, i64 36, i64 undef }, i64 [[X]], 2
; CHECK-NEXT: ret { i64, i64, i64 } [[C]]
;
%a = insertvalue {i64, i64, i64} undef, i64 24, 0
%b = insertvalue {i64, i64, i64} %a, i64 36, 1
%c = insertvalue {i64, i64, i64} %b, i64 %x, 2
ret {i64, i64, i64} %c
}
; Test(s) for overdefined values.
define internal {i64, i32} @struct4(i32 %x) {
; CHECK-LABEL: define internal { i64, i32 } @struct4
; CHECK-SAME: (i32 [[X:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = insertvalue { i64, i32 } { i64 12, i32 24 }, i32 [[X]], 1
; CHECK-NEXT: ret { i64, i32 } [[A]]
;
%a = insertvalue {i64, i32} {i64 12, i32 24}, i32 %x, 1
ret {i64, i32} %a
}
define internal {i32} @struct5(i32 %x) {
; CHECK-LABEL: define internal { i32 } @struct5
; CHECK-SAME: (i32 [[X:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = insertvalue { i32 } undef, i32 [[X]], 0
; CHECK-NEXT: ret { i32 } [[A]]
;
%a = insertvalue {i32} undef, i32 %x, 0
ret {i32} %a
}
define internal {i32} @struct6({i32} %x) {
; CHECK-LABEL: define internal { i32 } @struct6
; CHECK-SAME: ({ i32 } [[X:%.*]]) {
; CHECK-NEXT: ret { i32 } { i32 12 }
;
%a = insertvalue {i32} %x, i32 12, 0
ret {i32} %a
}
define internal {i16} @struct7() {
; CHECK-LABEL: define internal { i16 } @struct7() {
; CHECK-NEXT: ret { i16 } { i16 7 }
;
%a = insertvalue {i16} {i16 4}, i16 7, 0
ret {i16} %a
}