1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 define i32 @foo(i32 %a) {
6 ; CHECK-NEXT: [[T15:%.*]] = sub i32 99, [[A:%.*]]
7 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[T15]], 0
8 ; CHECK-NEXT: [[A_OP:%.*]] = add i32 [[A]], 1
9 ; CHECK-NEXT: [[T13:%.*]] = select i1 [[TMP1]], i32 100, i32 [[A_OP]]
10 ; CHECK-NEXT: ret i32 [[T13]]
13 %t16 = icmp slt i32 %t15, 0
14 %smax = select i1 %t16, i32 0, i32 %t15
15 %t12 = add i32 %smax, %a
16 %t13 = add i32 %t12, 1
20 define i32 @bar(i32 %a) {
22 ; CHECK-NEXT: [[T15:%.*]] = sub i32 99, [[A:%.*]]
23 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[T15]], 0
24 ; CHECK-NEXT: [[T12:%.*]] = select i1 [[TMP1]], i32 99, i32 [[A]]
25 ; CHECK-NEXT: ret i32 [[T12]]
28 %t16 = icmp slt i32 %t15, 0
29 %smax = select i1 %t16, i32 0, i32 %t15
30 %t12 = add i32 %smax, %a
34 define i32 @fun(i32 %a) {
36 ; CHECK-NEXT: [[T16:%.*]] = icmp slt i32 [[A:%.*]], 0
37 ; CHECK-NEXT: [[T12:%.*]] = select i1 [[T16]], i32 [[A]], i32 99
38 ; CHECK-NEXT: ret i32 [[T12]]
41 %t16 = icmp slt i32 %a, 0
42 %smax = select i1 %t16, i32 0, i32 %t15
43 %t12 = add i32 %smax, %a