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 @or2(i1 noundef %x, i1 %x2) {
34 ; CHECK-NEXT: [[Y:%.*]] = or i1 [[X:%.*]], [[X2:%.*]]
35 ; CHECK-NEXT: [[Z:%.*]] = freeze i1 [[Y]]
36 ; CHECK-NEXT: ret i1 [[Z]]
43 define i8 @add(i8 noundef %x) {
45 ; CHECK-NEXT: [[Y:%.*]] = add i8 [[X:%.*]], 1
46 ; CHECK-NEXT: ret i8 [[Y]]
53 define 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]]
64 define {i8, i32} @aggr({i8, i32} noundef %x) {
66 ; CHECK-NEXT: ret { i8, i32 } [[X:%.*]]
68 %y = freeze {i8, i32} %x
72 define 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]]
77 %y = extractvalue {i8, i32} %x, 1
82 define 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]]
88 %y = extractvalue {i8, {i8, i32}} %x, 1
89 %z = extractvalue {i8, i32} %y, 1
94 declare void @use_i1(i1 noundef)
96 define 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]]
102 %y = add nsw i1 %x, 1
103 call void @use_i1(i1 %y)
108 define i32 @noundef_metadata(ptr %p) {
109 ; CHECK-LABEL: @noundef_metadata(
110 ; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[P:%.*]], align 4, !noundef !0
111 ; CHECK-NEXT: ret i32 [[V]]
113 %v = load i32, ptr %p, !noundef !{}
114 %v.fr = freeze i32 %v
118 define {i8, i32} @noundef_metadata2(ptr %p) {
119 ; CHECK-LABEL: @noundef_metadata2(
120 ; CHECK-NEXT: [[V:%.*]] = load { i8, i32 }, ptr [[P:%.*]], align 4, !noundef !0
121 ; CHECK-NEXT: ret { i8, i32 } [[V]]
123 %v = load {i8, i32}, ptr %p, !noundef !{}
124 %v.fr = freeze {i8, i32} %v