1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -p constraint-elimination -S %s | FileCheck %s
4 ; Tests for https://github.com/llvm/llvm-project/issues/78621.
6 define i1 @umin_not_used(i32 %arg) {
7 ; CHECK-LABEL: define i1 @umin_not_used(
8 ; CHECK-SAME: i32 [[ARG:%.*]]) {
9 ; CHECK-NEXT: [[ICMP:%.*]] = icmp slt i32 [[ARG]], 0
10 ; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
11 ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
12 ; CHECK-NEXT: [[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
13 ; CHECK-NEXT: ret i1 [[ICMP]]
15 %icmp = icmp slt i32 %arg, 0
16 %shl = shl nuw nsw i32 %arg, 3
17 call i32 @llvm.umin.i32(i32 %shl, i32 80)
18 %cmp2 = shl nuw nsw i32 %arg, 3
22 define i1 @umin_poison_is_UB_via_call(i32 %arg) {
23 ; CHECK-LABEL: define i1 @umin_poison_is_UB_via_call(
24 ; CHECK-SAME: i32 [[ARG:%.*]]) {
25 ; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
26 ; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
27 ; CHECK-NEXT: call void @noundef(i32 noundef [[MIN]])
28 ; CHECK-NEXT: [[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
29 ; CHECK-NEXT: ret i1 false
31 %icmp = icmp slt i32 %arg, 0
32 %shl = shl nuw nsw i32 %arg, 3
33 %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
34 call void @noundef(i32 noundef %min)
35 %cmp2 = shl nuw nsw i32 %arg, 3
39 define i1 @umin_poison_call_before_UB(i32 %arg) {
40 ; CHECK-LABEL: define i1 @umin_poison_call_before_UB(
41 ; CHECK-SAME: i32 [[ARG:%.*]]) {
42 ; CHECK-NEXT: [[ICMP:%.*]] = icmp slt i32 [[ARG]], 0
43 ; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
44 ; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
45 ; CHECK-NEXT: call void @fn()
46 ; CHECK-NEXT: call void @noundef(i32 noundef [[MIN]])
47 ; CHECK-NEXT: [[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
48 ; CHECK-NEXT: ret i1 [[ICMP]]
50 %icmp = icmp slt i32 %arg, 0
51 %shl = shl nuw nsw i32 %arg, 3
52 %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
54 call void @noundef(i32 noundef %min)
55 %cmp2 = shl nuw nsw i32 %arg, 3
59 declare i32 @llvm.umin.i32(i32, i32) #0
61 declare void @noundef(i32 noundef)