1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt -O1 -S < %s | FileCheck %s
4 define i32 @testa(i32 %mul) {
5 ; CHECK-LABEL: define i32 @testa(
6 ; CHECK-SAME: i32 [[MUL:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
7 ; CHECK-NEXT: [[SHR:%.*]] = ashr i32 [[MUL]], 15
8 ; CHECK-NEXT: [[SPEC_SELECT_I:%.*]] = tail call i32 @llvm.smin.i32(i32 [[SHR]], i32 32767)
9 ; CHECK-NEXT: ret i32 [[SPEC_SELECT_I]]
11 %shr = ashr i32 %mul, 15
12 %cmp4.i = icmp sgt i32 %shr, 32767
13 %switch.i = icmp ult i1 %cmp4.i, true
14 %spec.select.i = select i1 %switch.i, i32 %shr, i32 32767
15 ret i32 %spec.select.i
18 define i32 @testb(i32 %mul) {
19 ; CHECK-LABEL: define i32 @testb(
20 ; CHECK-SAME: i32 [[MUL:%.*]]) local_unnamed_addr #[[ATTR0]] {
21 ; CHECK-NEXT: [[SHR102:%.*]] = ashr i32 [[MUL]], 7
22 ; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.smax.i32(i32 [[SHR102]], i32 -128)
23 ; CHECK-NEXT: [[SPEC_SELECT_I:%.*]] = tail call i32 @llvm.smin.i32(i32 [[TMP1]], i32 127)
24 ; CHECK-NEXT: ret i32 [[SPEC_SELECT_I]]
26 %shr102 = ashr i32 %mul, 7
27 %cmp4.i = icmp sgt i32 %shr102, 127
28 %cmp6.i = icmp slt i32 %shr102, -128
29 %retval.0.i = select i1 %cmp4.i, i32 127, i32 -128
30 %cleanup.dest.slot.0.i = select i1 %cmp4.i, i1 true, i1 %cmp6.i
31 %switch.i = icmp ult i1 %cleanup.dest.slot.0.i, true
32 %spec.select.i = select i1 %switch.i, i32 %shr102, i32 %retval.0.i
33 ret i32 %spec.select.i