xref: /aosp_15_r20/external/llvm/test/Transforms/ConstProp/insertvalue.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -constprop -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker%struct = type { i32, [4 x i8] }
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdefine %struct @test1() {
6*9880d681SAndroid Build Coastguard Worker  %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i32 1, 0
7*9880d681SAndroid Build Coastguard Worker  ret %struct %A
8*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test1(
9*9880d681SAndroid Build Coastguard Worker; CHECK: ret %struct { i32 1, [4 x i8] c"foo\00" }
10*9880d681SAndroid Build Coastguard Worker}
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine %struct @test2() {
13*9880d681SAndroid Build Coastguard Worker  %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i8 1, 1, 2
14*9880d681SAndroid Build Coastguard Worker  ret %struct %A
15*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test2(
16*9880d681SAndroid Build Coastguard Worker; CHECK: ret %struct { i32 2, [4 x i8] c"fo\01\00" }
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Workerdefine [3 x %struct] @test3() {
20*9880d681SAndroid Build Coastguard Worker  %A = insertvalue [3 x %struct] [ %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
21*9880d681SAndroid Build Coastguard Worker  ret [3 x %struct] %A
22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test3(
23*9880d681SAndroid Build Coastguard Worker; CHECK:ret [3 x %struct] [%struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 -1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" }]
24*9880d681SAndroid Build Coastguard Worker}
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workerdefine %struct @zeroinitializer-test1() {
27*9880d681SAndroid Build Coastguard Worker  %A = insertvalue %struct zeroinitializer, i32 1, 0
28*9880d681SAndroid Build Coastguard Worker  ret %struct %A
29*9880d681SAndroid Build Coastguard Worker; CHECK: @zeroinitializer-test1
30*9880d681SAndroid Build Coastguard Worker; CHECK: ret %struct { i32 1, [4 x i8] zeroinitializer }
31*9880d681SAndroid Build Coastguard Worker}
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Workerdefine %struct @zeroinitializer-test2() {
34*9880d681SAndroid Build Coastguard Worker  %A = insertvalue %struct zeroinitializer, i8 1, 1, 2
35*9880d681SAndroid Build Coastguard Worker  ret %struct %A
36*9880d681SAndroid Build Coastguard Worker; CHECK: @zeroinitializer-test2
37*9880d681SAndroid Build Coastguard Worker; CHECK: ret %struct { i32 0, [4 x i8] c"\00\00\01\00" }
38*9880d681SAndroid Build Coastguard Worker}
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workerdefine [3 x %struct] @zeroinitializer-test3() {
41*9880d681SAndroid Build Coastguard Worker  %A = insertvalue [3 x %struct] zeroinitializer, i32 1, 1, 0
42*9880d681SAndroid Build Coastguard Worker  ret [3 x %struct] %A
43*9880d681SAndroid Build Coastguard Worker; CHECK: @zeroinitializer-test3
44*9880d681SAndroid Build Coastguard Worker; CHECK: ret [3 x %struct] [%struct zeroinitializer, %struct { i32 1, [4 x i8] zeroinitializer }, %struct zeroinitializer]
45*9880d681SAndroid Build Coastguard Worker}
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerdefine %struct @undef-test1() {
48*9880d681SAndroid Build Coastguard Worker  %A = insertvalue %struct undef, i32 1, 0
49*9880d681SAndroid Build Coastguard Worker  ret %struct %A
50*9880d681SAndroid Build Coastguard Worker; CHECK: @undef-test1
51*9880d681SAndroid Build Coastguard Worker; CHECK: ret %struct { i32 1, [4 x i8] undef }
52*9880d681SAndroid Build Coastguard Worker}
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Workerdefine %struct @undef-test2() {
55*9880d681SAndroid Build Coastguard Worker  %A = insertvalue %struct undef, i8 0, 1, 2
56*9880d681SAndroid Build Coastguard Worker  ret %struct %A
57*9880d681SAndroid Build Coastguard Worker; CHECK: @undef-test2
58*9880d681SAndroid Build Coastguard Worker; CHECK: ret %struct { i32 undef, [4 x i8] [i8 undef, i8 undef, i8 0, i8 undef] }
59*9880d681SAndroid Build Coastguard Worker}
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Workerdefine [3 x %struct] @undef-test3() {
62*9880d681SAndroid Build Coastguard Worker  %A = insertvalue [3 x %struct] undef, i32 0, 1, 0
63*9880d681SAndroid Build Coastguard Worker  ret [3 x %struct] %A
64*9880d681SAndroid Build Coastguard Worker; CHECK: @undef-test3
65*9880d681SAndroid Build Coastguard Worker; CHECK: ret [3 x %struct] [%struct undef, %struct { i32 0, [4 x i8] undef }, %struct undef]
66*9880d681SAndroid Build Coastguard Worker}
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Workerdefine i32 @test-float-Nan() {
69*9880d681SAndroid Build Coastguard Worker  %A = bitcast i32 2139171423 to float
70*9880d681SAndroid Build Coastguard Worker  %B = insertvalue [1 x float] undef, float %A, 0
71*9880d681SAndroid Build Coastguard Worker  %C = extractvalue [1 x float] %B, 0
72*9880d681SAndroid Build Coastguard Worker  %D = bitcast float %C to i32
73*9880d681SAndroid Build Coastguard Worker  ret i32 %D
74*9880d681SAndroid Build Coastguard Worker; CHECK: @test-float-Nan
75*9880d681SAndroid Build Coastguard Worker; CHECK: ret i32 2139171423
76*9880d681SAndroid Build Coastguard Worker}
77*9880d681SAndroid Build Coastguard Worker
78*9880d681SAndroid Build Coastguard Workerdefine i16 @test-half-Nan() {
79*9880d681SAndroid Build Coastguard Worker  %A = bitcast i16 32256 to half
80*9880d681SAndroid Build Coastguard Worker  %B = insertvalue [1 x half] undef, half %A, 0
81*9880d681SAndroid Build Coastguard Worker  %C = extractvalue [1 x half] %B, 0
82*9880d681SAndroid Build Coastguard Worker  %D = bitcast half %C to i16
83*9880d681SAndroid Build Coastguard Worker  ret i16 %D
84*9880d681SAndroid Build Coastguard Worker; CHECK: @test-half-Nan
85*9880d681SAndroid Build Coastguard Worker; CHECK: ret i16 32256
86*9880d681SAndroid Build Coastguard Worker}
87