1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -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: [[CMP:%.*]] = icmp ult i32 [[LEN:%.*]], 8
13 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[LEN]], i32 8
14 ; CHECK-NEXT: [[CMP11_NOT:%.*]] = icmp eq i32 [[COND]], 0
15 ; CHECK-NEXT: br i1 [[CMP11_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY:%.*]]
17 ; CHECK-NEXT: [[I_02:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
18 ; CHECK-NEXT: tail call void @f(i32 [[COND]])
19 ; CHECK-NEXT: [[INC]] = add i32 [[I_02]], 1
20 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[INC]], [[COND]]
21 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY]], label [[FOR_END]]
23 ; CHECK-NEXT: ret void
26 %cmp = icmp ult i32 %len, 8
27 %cond = select i1 %cmp, i32 %len, i32 8
28 %cmp11 = icmp ult i32 0, %cond
29 br i1 %cmp11, label %for.body, label %for.end
31 for.body: ; preds = %entry, %for.body
32 %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
33 tail call void @f(i32 %cond)
34 %inc = add i32 %i.02, 1
35 %cmp1 = icmp ult i32 %inc, %cond
36 br i1 %cmp1, label %for.body, label %for.end
38 for.end: ; preds = %for.body, %entry