1; RUN: opt < %s -simple-loop-unswitch -S 2>&1 | FileCheck %s
2
3; This is to test trivial loop unswitch only happens when trivial condition
4; itself is an LIV loop condition (not partial LIV which could occur in and/or).
5
6define i32 @test(i1 %cond1, i32 %var1) {
7; CHECK-LABEL: define i32 @test(
8entry:
9  br label %loop_begin
10; CHECK-NEXT:  entry:
11; CHECK-NEXT:    br i1 %cond1, label %entry.split, label %loop_exit.split
12;
13; CHECK:       entry.split:
14; CHECK-NEXT:    br label %loop_begin
15
16loop_begin:
17  %var3 = phi i32 [%var1, %entry], [%var2, %do_something]
18  %cond2 = icmp eq i32 %var3, 10
19  %cond.and = and i1 %cond1, %cond2
20  br i1 %cond.and, label %do_something, label %loop_exit
21; CHECK:       loop_begin:
22; CHECK-NEXT:    %[[VAR3:.*]] = phi i32
23; CHECK-NEXT:    %[[COND2:.*]] = icmp eq i32 %[[VAR3]], 10
24; CHECK-NEXT:    %[[COND_AND:.*]] = and i1 true, %[[COND2]]
25; CHECK-NEXT:    br i1 %[[COND_AND]], label %do_something, label %loop_exit
26
27do_something:
28  %var2 = add i32 %var3, 1
29  call void @some_func() noreturn nounwind
30  br label %loop_begin
31
32loop_exit:
33  ret i32 0
34}
35
36declare void @some_func() noreturn
37