2 ; RUN: opt -loop-unswitch -enable-new-pm=0 -loop-unswitch-threshold 13 -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s
3 ; RUN: opt -S -loop-unswitch -enable-new-pm=0 -loop-unswitch-threshold 13 -verify-loop-info -verify-dom-info -verify-memoryssa < %s | FileCheck %s
5 ; STATS: 1 loop-unswitch - Number of switches unswitched
7 ; ModuleID = '../llvm/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll'
9 ; CHECK: %1 = icmp eq i32 %c, 1
10 ; CHECK-NEXT: br i1 %1, label %.split.us, label %..split_crit_edge
12 ; CHECK: ..split_crit_edge: ; preds = %0
13 ; CHECK-NEXT: br label %.split
15 ; CHECK: .split.us: ; preds = %0
16 ; CHECK-NEXT: br label %loop_begin.us
18 ; CHECK: loop_begin.us: ; preds = %loop_begin.backedge.us, %.split.us
19 ; CHECK: switch i32 1, label %second_switch.us [
20 ; CHECK-NEXT: i32 1, label %inc.us
22 ; CHECK: second_switch.us: ; preds = %loop_begin.us
23 ; CHECK-NEXT: switch i32 %d, label %default.us [
24 ; CHECK-NEXT: i32 1, label %inc.us
27 ; CHECK: inc.us: ; preds = %second_switch.us, %loop_begin.us
28 ; CHECK-NEXT: call void @incf() [[NOR_NUW:#[0-9]+]]
29 ; CHECK-NEXT: br label %loop_begin.backedge.us
31 ; CHECK: .split: ; preds = %..split_crit_edge
32 ; CHECK-NEXT: br label %loop_begin
34 ; CHECK: loop_begin: ; preds = %loop_begin.backedge, %.split
35 ; CHECK: switch i32 %c, label %second_switch [
36 ; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge
39 ; CHECK: loop_begin.inc_crit_edge: ; preds = %loop_begin
40 ; CHECK-NEXT: br i1 true, label %us-unreachable, label %inc
42 ; CHECK: second_switch: ; preds = %loop_begin
43 ; CHECK-NEXT: switch i32 %d, label %default [
44 ; CHECK-NEXT: i32 1, label %inc
47 ; CHECK: inc: ; preds = %loop_begin.inc_crit_edge, %second_switch
48 ; CHECK-NEXT: call void @incf() [[NOR_NUW]]
49 ; CHECK-NEXT: br label %loop_begin.backedge
51 define i32 @test(i32* %var) {
53 store i32 2, i32* %mem
54 %c = load i32, i32* %mem
55 %d = load i32, i32* %mem
61 %var_val = load i32, i32* %var
63 switch i32 %c, label %second_switch [
68 switch i32 %d, label %default [
73 call void @incf() noreturn nounwind
83 declare void @incf() noreturn
84 declare void @decf() noreturn
86 ; CHECK: attributes #0 = { noreturn }
87 ; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind }