• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -passes='loop(loop-instsimplify,simplify-cfg,unswitch),verify<loops>' -S < %s | FileCheck %s
2
3declare void @some_func() noreturn
4
5define i32 @test1(i32* %var, i1 %cond1, i1 %cond2) {
6; CHECK-LABEL: @test1(
7entry:
8  br label %loop_begin
9; CHECK-NEXT:  entry:
10; CHECK-NEXT:    br i1 %{{.*}}, label %entry.split, label %loop_exit.split
11;
12; CHECK:       entry.split:
13; CHECK-NEXT:    br i1 %{{.*}}, label %entry.split.split, label %loop_exit
14;
15; CHECK:       entry.split.split:
16; CHECK-NEXT:    br label %loop_begin
17
18loop_begin:
19  br i1 %cond1, label %continue, label %loop_exit ; first trivial condition
20
21continue:
22  %var_val = load i32, i32* %var
23  %var_cond = trunc i32 %var_val to i1
24  %maybe_cond = select i1 %cond1, i1 %cond2, i1 %var_cond
25  br i1 %maybe_cond, label %do_something, label %loop_exit ; second trivial condition
26
27do_something:
28  call void @some_func() noreturn nounwind
29  br label %loop_begin
30; CHECK:       loop_begin:
31; CHECK-NEXT:    call
32; CHECK-NEXT:    br label %loop_begin
33
34loop_exit:
35  ret i32 0
36; CHECK:       loop_exit:
37; CHECK-NEXT:    br label %loop_exit.split
38;
39; CHECK:       loop_exit.split:
40; CHECK-NEXT:    ret
41}
42