2 ; RUN: opt -loop-unswitch -loop-unswitch-threshold 13 -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s
3 ; RUN: opt -S -loop-unswitch -loop-unswitch-threshold 13 -verify-loop-info -verify-dom-info < %s | FileCheck %s
4 ; RUN: opt -S -loop-unswitch -loop-unswitch-threshold 13 -verify-loop-info -verify-dom-info -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s
6 ; STATS: 1 loop-unswitch - Number of switches unswitched
8 ; ModuleID = '../llvm/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll'
10 ; CHECK: %1 = icmp eq i32 %c, 1
11 ; CHECK-NEXT: br i1 %1, label %.split.us, label %..split_crit_edge
13 ; CHECK: ..split_crit_edge: ; preds = %0
14 ; CHECK-NEXT: br label %.split
16 ; CHECK: .split.us: ; preds = %0
17 ; CHECK-NEXT: br label %loop_begin.us
19 ; CHECK: loop_begin.us: ; preds = %loop_begin.backedge.us, %.split.us
20 ; CHECK: switch i32 1, label %second_switch.us [
21 ; CHECK-NEXT: i32 1, label %inc.us
23 ; CHECK: second_switch.us: ; preds = %loop_begin.us
24 ; CHECK-NEXT: switch i32 %d, label %default.us [
25 ; CHECK-NEXT: i32 1, label %inc.us
28 ; CHECK: inc.us: ; preds = %second_switch.us, %loop_begin.us
29 ; CHECK-NEXT: call void @incf() [[NOR_NUW:#[0-9]+]]
30 ; CHECK-NEXT: br label %loop_begin.backedge.us
32 ; CHECK: .split: ; preds = %..split_crit_edge
33 ; CHECK-NEXT: br label %loop_begin
35 ; CHECK: loop_begin: ; preds = %loop_begin.backedge, %.split
36 ; CHECK: switch i32 %c, label %second_switch [
37 ; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge
40 ; CHECK: loop_begin.inc_crit_edge: ; preds = %loop_begin
41 ; CHECK-NEXT: br i1 true, label %us-unreachable, label %inc
43 ; CHECK: second_switch: ; preds = %loop_begin
44 ; CHECK-NEXT: switch i32 %d, label %default [
45 ; CHECK-NEXT: i32 1, label %inc
48 ; CHECK: inc: ; preds = %loop_begin.inc_crit_edge, %second_switch
49 ; CHECK-NEXT: call void @incf() [[NOR_NUW]]
50 ; CHECK-NEXT: br label %loop_begin.backedge
52 define i32 @test(i32* %var) {
54 store i32 2, i32* %mem
55 %c = load i32, i32* %mem
56 %d = load i32, i32* %mem
62 %var_val = load i32, i32* %var
64 switch i32 %c, label %second_switch [
69 switch i32 %d, label %default [
74 call void @incf() noreturn nounwind
84 declare void @incf() noreturn
85 declare void @decf() noreturn
87 ; CHECK: attributes #0 = { noreturn }
88 ; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind }