1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
8 ; Do not replace a 'select' with 'or' in 'select - cmp - br' sequence
9 define void @test(i32 %len) {
12 ; CHECK-NEXT: [[COND:%.*]] = call i32 @llvm.umin.i32(i32 [[LEN:%.*]], i32 8)
13 ; CHECK-NEXT: [[CMP11_NOT:%.*]] = icmp eq i32 [[LEN]], 0
14 ; CHECK-NEXT: br i1 [[CMP11_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY:%.*]]
16 ; CHECK-NEXT: [[I_02:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
17 ; CHECK-NEXT: tail call void @f(i32 [[COND]])
18 ; CHECK-NEXT: [[INC]] = add i32 [[I_02]], 1
19 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[INC]], [[COND]]
20 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY]], label [[FOR_END]]
22 ; CHECK-NEXT: ret void
25 %cmp = icmp ult i32 %len, 8
26 %cond = select i1 %cmp, i32 %len, i32 8
27 %cmp11 = icmp ult i32 0, %cond
28 br i1 %cmp11, label %for.body, label %for.end
30 for.body: ; preds = %entry, %for.body
31 %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
32 tail call void @f(i32 %cond)
33 %inc = add i32 %i.02, 1
34 %cmp1 = icmp ult i32 %inc, %cond
35 br i1 %cmp1, label %for.body, label %for.end
37 for.end: ; preds = %for.body, %entry