• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instsimplify -S | FileCheck %s
3
4define i8 @noundef(i8 noundef %x) {
5; CHECK-LABEL: @noundef(
6; CHECK-NEXT:    ret i8 [[X:%.*]]
7;
8  %y = freeze i8 %x
9  ret i8 %y
10}
11
12define i1 @icmp(i8 noundef %x, i8 noundef %y) {
13; CHECK-LABEL: @icmp(
14; CHECK-NEXT:    [[C:%.*]] = icmp eq i8 [[X:%.*]], [[Y:%.*]]
15; CHECK-NEXT:    ret i1 [[C]]
16;
17  %c = icmp eq i8 %x, %y
18  %f = freeze i1 %c
19  ret i1 %f
20}
21
22define i1 @or(i1 noundef %x, i1 noundef %x2) {
23; CHECK-LABEL: @or(
24; CHECK-NEXT:    [[Y:%.*]] = or i1 [[X:%.*]], [[X2:%.*]]
25; CHECK-NEXT:    ret i1 [[Y]]
26;
27  %y = or i1 %x, %x2
28  %z = freeze i1 %y
29  ret i1 %z
30}
31
32define i1 @or2(i1 noundef %x, i1 %x2) {
33; CHECK-LABEL: @or2(
34; CHECK-NEXT:    [[Y:%.*]] = or i1 [[X:%.*]], [[X2:%.*]]
35; CHECK-NEXT:    [[Z:%.*]] = freeze i1 [[Y]]
36; CHECK-NEXT:    ret i1 [[Z]]
37;
38  %y = or i1 %x, %x2
39  %z = freeze i1 %y
40  ret i1 %z
41}
42
43define i8 @add(i8 noundef %x) {
44; CHECK-LABEL: @add(
45; CHECK-NEXT:    [[Y:%.*]] = add i8 [[X:%.*]], 1
46; CHECK-NEXT:    ret i8 [[Y]]
47;
48  %y = add i8 %x, 1
49  %z = freeze i8 %y
50  ret i8 %z
51}
52
53define i8 @addnsw(i8 noundef %x) {
54; CHECK-LABEL: @addnsw(
55; CHECK-NEXT:    [[Y:%.*]] = add nsw i8 [[X:%.*]], 1
56; CHECK-NEXT:    [[Z:%.*]] = freeze i8 [[Y]]
57; CHECK-NEXT:    ret i8 [[Z]]
58;
59  %y = add nsw i8 %x, 1
60  %z = freeze i8 %y
61  ret i8 %z
62}
63
64define {i8, i32} @aggr({i8, i32} noundef %x) {
65; CHECK-LABEL: @aggr(
66; CHECK-NEXT:    ret { i8, i32 } [[X:%.*]]
67;
68  %y = freeze {i8, i32} %x
69  ret {i8, i32} %y
70}
71
72define i32 @extract({i8, i32} noundef %x) {
73; CHECK-LABEL: @extract(
74; CHECK-NEXT:    [[Y:%.*]] = extractvalue { i8, i32 } [[X:%.*]], 1
75; CHECK-NEXT:    ret i32 [[Y]]
76;
77  %y = extractvalue {i8, i32} %x, 1
78  %z = freeze i32 %y
79  ret i32 %z
80}
81
82define i32 @extract2({i8, {i8, i32}} noundef %x) {
83; CHECK-LABEL: @extract2(
84; CHECK-NEXT:    [[Y:%.*]] = extractvalue { i8, { i8, i32 } } [[X:%.*]], 1
85; CHECK-NEXT:    [[Z:%.*]] = extractvalue { i8, i32 } [[Y]], 1
86; CHECK-NEXT:    ret i32 [[Z]]
87;
88  %y = extractvalue {i8, {i8, i32}} %x, 1
89  %z = extractvalue {i8, i32} %y, 1
90  %w = freeze i32 %z
91  ret i32 %w
92}
93
94declare void @use_i1(i1 noundef)
95
96define i1 @used_by_fncall(i1 %x) {
97; CHECK-LABEL: @used_by_fncall(
98; CHECK-NEXT:    [[Y:%.*]] = add nsw i1 [[X:%.*]], true
99; CHECK-NEXT:    call void @use_i1(i1 [[Y]])
100; CHECK-NEXT:    ret i1 [[Y]]
101;
102  %y = add nsw i1 %x, 1
103  call void @use_i1(i1 %y)
104  %f = freeze i1 %y
105  ret i1 %f
106}
107
108define i32 @noundef_metadata(i32* %p) {
109; CHECK-LABEL: @noundef_metadata(
110; CHECK-NEXT:    [[V:%.*]] = load i32, i32* [[P:%.*]], align 4, !noundef !0
111; CHECK-NEXT:    ret i32 [[V]]
112;
113  %v = load i32, i32* %p, !noundef !{}
114  %v.fr = freeze i32 %v
115  ret i32 %v.fr
116}
117
118define {i8, i32} @noundef_metadata2({i8, i32}* %p) {
119; CHECK-LABEL: @noundef_metadata2(
120; CHECK-NEXT:    [[V:%.*]] = load { i8, i32 }, { i8, i32 }* [[P:%.*]], align 4, !noundef !0
121; CHECK-NEXT:    ret { i8, i32 } [[V]]
122;
123  %v = load {i8, i32}, {i8, i32}* %p, !noundef !{}
124  %v.fr = freeze {i8, i32} %v
125  ret {i8, i32} %v.fr
126}
127