xref: /llvm-project/llvm/test/Transforms/InstSimplify/insertvalue.ll (revision 9ca2c309ab0678fae48f96131b92754d0978c130)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
3
4define {i32, i32} @insert_poison({i32, i32} %x) {
5; CHECK-LABEL: @insert_poison(
6; CHECK-NEXT:    ret { i32, i32 } [[X:%.*]]
7;
8  %v = insertvalue {i32, i32} %x, i32 poison, 0
9  ret {i32, i32} %v
10}
11
12define {i32, i32} @insert_undef({i32, i32} %x) {
13; CHECK-LABEL: @insert_undef(
14; CHECK-NEXT:    [[V:%.*]] = insertvalue { i32, i32 } [[X:%.*]], i32 undef, 0
15; CHECK-NEXT:    ret { i32, i32 } [[V]]
16;
17  %v = insertvalue {i32, i32} %x, i32 undef, 0
18  ret {i32, i32} %v
19}
20
21define {i32, i32} @insert_undef_into_non_poison({i32, i32} noundef %x) {
22; CHECK-LABEL: @insert_undef_into_non_poison(
23; CHECK-NEXT:    ret { i32, i32 } [[X:%.*]]
24;
25  %v = insertvalue {i32, i32} %x, i32 undef, 0
26  ret {i32, i32} %v
27}
28
29define {i32, i32} @insert_into_poison({i32, i32} %x) {
30; CHECK-LABEL: @insert_into_poison(
31; CHECK-NEXT:    ret { i32, i32 } [[X:%.*]]
32;
33  %elem = extractvalue {i32, i32} %x, 0
34  %v = insertvalue {i32, i32} poison, i32 %elem, 0
35  ret {i32, i32} %v
36}
37
38define {i32, i32} @insert_into_undef({i32, i32} %x) {
39; CHECK-LABEL: @insert_into_undef(
40; CHECK-NEXT:    [[ELEM:%.*]] = extractvalue { i32, i32 } [[X:%.*]], 0
41; CHECK-NEXT:    [[V:%.*]] = insertvalue { i32, i32 } undef, i32 [[ELEM]], 0
42; CHECK-NEXT:    ret { i32, i32 } [[V]]
43;
44  %elem = extractvalue {i32, i32} %x, 0
45  %v = insertvalue {i32, i32} undef, i32 %elem, 0
46  ret {i32, i32} %v
47}
48
49define {i32, i32} @insert_non_poison_into_undef({i32, i32} noundef %x) {
50; CHECK-LABEL: @insert_non_poison_into_undef(
51; CHECK-NEXT:    ret { i32, i32 } [[X:%.*]]
52;
53  %elem = extractvalue {i32, i32} %x, 0
54  %v = insertvalue {i32, i32} undef, i32 %elem, 0
55  ret {i32, i32} %v
56}
57