1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 ; Instcombine normally would fold the sdiv into the comparison,
5 ; making "icmp slt i32 %h, 2", but in this case the sdiv has
6 ; another use, so it wouldn't a big win, and it would also
7 ; obfuscate an otherise obvious smax pattern to the point where
8 ; other analyses wouldn't recognize it.
10 define i32 @foo(i32 %h) {
12 ; CHECK-NEXT: [[SD:%.*]] = sdiv i32 [[H:%.*]], 2
13 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.smin.i32(i32 [[SD]], i32 1)
14 ; CHECK-NEXT: ret i32 [[R]]
17 %t = icmp slt i32 %sd, 1
18 %r = select i1 %t, i32 %sd, i32 1
22 define i32 @bar(i32 %h) {
24 ; CHECK-NEXT: [[SD:%.*]] = sdiv i32 [[H:%.*]], 2
25 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.smax.i32(i32 [[SD]], i32 1)
26 ; CHECK-NEXT: ret i32 [[R]]
29 %t = icmp sgt i32 %sd, 1
30 %r = select i1 %t, i32 %sd, i32 1