1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 define i8 @noundef(i8 noundef %x) {
5 ; CHECK-LABEL: @noundef(
6 ; CHECK-NEXT: ret i8 [[X:%.*]]
12 define i1 @icmp(i8 noundef %x, i8 noundef %y) {
14 ; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[X:%.*]], [[Y:%.*]]
15 ; CHECK-NEXT: ret i1 [[C]]
17 %c = icmp eq i8 %x, %y
22 define i1 @or(i1 noundef %x, i1 noundef %x2) {
24 ; CHECK-NEXT: [[Y:%.*]] = or i1 [[X:%.*]], [[X2:%.*]]
25 ; CHECK-NEXT: ret i1 [[Y]]
32 define i1 @or_disjoint(i1 noundef %x, i1 noundef %x2) {
33 ; CHECK-LABEL: @or_disjoint(
34 ; CHECK-NEXT: [[Y:%.*]] = or disjoint i1 [[X:%.*]], [[X2:%.*]]
35 ; CHECK-NEXT: [[Z:%.*]] = freeze i1 [[Y]]
36 ; CHECK-NEXT: ret i1 [[Z]]
38 %y = or disjoint i1 %x, %x2
43 define i1 @or2(i1 noundef %x, i1 %x2) {
45 ; CHECK-NEXT: [[Y:%.*]] = or i1 [[X:%.*]], [[X2:%.*]]
46 ; CHECK-NEXT: [[Z:%.*]] = freeze i1 [[Y]]
47 ; CHECK-NEXT: ret i1 [[Z]]
54 define i8 @add(i8 noundef %x) {
56 ; CHECK-NEXT: [[Y:%.*]] = add i8 [[X:%.*]], 1
57 ; CHECK-NEXT: ret i8 [[Y]]
64 define i8 @addnsw(i8 noundef %x) {
65 ; CHECK-LABEL: @addnsw(
66 ; CHECK-NEXT: [[Y:%.*]] = add nsw i8 [[X:%.*]], 1
67 ; CHECK-NEXT: [[Z:%.*]] = freeze i8 [[Y]]
68 ; CHECK-NEXT: ret i8 [[Z]]
75 define i16 @zext(i8 noundef %x) {
77 ; CHECK-NEXT: [[Y:%.*]] = zext i8 [[X:%.*]] to i16
78 ; CHECK-NEXT: ret i16 [[Y]]
80 %y = zext i8 %x to i16
85 define i16 @zext_nneg(i8 noundef %x) {
86 ; CHECK-LABEL: @zext_nneg(
87 ; CHECK-NEXT: [[Y:%.*]] = zext nneg i8 [[X:%.*]] to i16
88 ; CHECK-NEXT: [[Z:%.*]] = freeze i16 [[Y]]
89 ; CHECK-NEXT: ret i16 [[Z]]
91 %y = zext nneg i8 %x to i16
96 define {i8, i32} @aggr({i8, i32} noundef %x) {
98 ; CHECK-NEXT: ret { i8, i32 } [[X:%.*]]
100 %y = freeze {i8, i32} %x
104 define i32 @extract({i8, i32} noundef %x) {
105 ; CHECK-LABEL: @extract(
106 ; CHECK-NEXT: [[Y:%.*]] = extractvalue { i8, i32 } [[X:%.*]], 1
107 ; CHECK-NEXT: ret i32 [[Y]]
109 %y = extractvalue {i8, i32} %x, 1
114 define i32 @extract2({i8, {i8, i32}} noundef %x) {
115 ; CHECK-LABEL: @extract2(
116 ; CHECK-NEXT: [[Y:%.*]] = extractvalue { i8, { i8, i32 } } [[X:%.*]], 1
117 ; CHECK-NEXT: [[Z:%.*]] = extractvalue { i8, i32 } [[Y]], 1
118 ; CHECK-NEXT: ret i32 [[Z]]
120 %y = extractvalue {i8, {i8, i32}} %x, 1
121 %z = extractvalue {i8, i32} %y, 1
126 declare void @use_i1(i1 noundef)
128 define i1 @used_by_fncall(i1 %x) {
129 ; CHECK-LABEL: @used_by_fncall(
130 ; CHECK-NEXT: [[Y:%.*]] = add nsw i1 [[X:%.*]], true
131 ; CHECK-NEXT: call void @use_i1(i1 [[Y]])
132 ; CHECK-NEXT: ret i1 [[Y]]
134 %y = add nsw i1 %x, 1
135 call void @use_i1(i1 %y)
140 define i32 @noundef_metadata(ptr %p) {
141 ; CHECK-LABEL: @noundef_metadata(
142 ; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[P:%.*]], align 4, !noundef [[META0:![0-9]+]]
143 ; CHECK-NEXT: ret i32 [[V]]
145 %v = load i32, ptr %p, !noundef !{}
146 %v.fr = freeze i32 %v
150 define {i8, i32} @noundef_metadata2(ptr %p) {
151 ; CHECK-LABEL: @noundef_metadata2(
152 ; CHECK-NEXT: [[V:%.*]] = load { i8, i32 }, ptr [[P:%.*]], align 4, !noundef [[META0]]
153 ; CHECK-NEXT: ret { i8, i32 } [[V]]
155 %v = load {i8, i32}, ptr %p, !noundef !{}
156 %v.fr = freeze {i8, i32} %v