From fa785cb22d50c657eb08c762d627cd6aa96982f3 Mon Sep 17 00:00:00 2001 From: Jan Wen Voung Date: Fri, 8 Mar 2013 22:56:31 +0000 Subject: Disable statistics on Release builds and move tests that depend on -stats. Summary: Statistics are still available in Release+Asserts (any +Asserts builds), and stats can also be turned on with LLVM_ENABLE_STATS. Move some of the FastISel stats that were moved under DEBUG() back out of DEBUG(), since stats are disabled across the board now. Many tests depend on grepping "-stats" output. Move those into a orig_dir/Stats/. so that they can be marked as unsupported when building without statistics. Differential Revision: http://llvm-reviews.chandlerc.com/D486 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176733 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../LoopUnswitch/2008-11-03-Invariant.ll | 36 ------ .../LoopUnswitch/2011-11-18-SimpleSwitch.ll | 94 -------------- .../2011-11-18-TwoSwitches-Threshold.ll | 87 ------------- .../LoopUnswitch/2011-11-18-TwoSwitches.ll | 141 --------------------- .../LoopUnswitch/Stats/2008-11-03-Invariant.ll | 36 ++++++ .../LoopUnswitch/Stats/2011-11-18-SimpleSwitch.ll | 94 ++++++++++++++ .../Stats/2011-11-18-TwoSwitches-Threshold.ll | 87 +++++++++++++ .../LoopUnswitch/Stats/2011-11-18-TwoSwitches.ll | 141 +++++++++++++++++++++ .../Transforms/LoopUnswitch/Stats/infinite-loop.ll | 57 +++++++++ test/Transforms/LoopUnswitch/Stats/lit.local.cfg | 4 + test/Transforms/LoopUnswitch/infinite-loop.ll | 57 --------- 11 files changed, 419 insertions(+), 415 deletions(-) delete mode 100644 test/Transforms/LoopUnswitch/2008-11-03-Invariant.ll delete mode 100644 test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll delete mode 100644 test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll delete mode 100644 test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll create mode 100644 test/Transforms/LoopUnswitch/Stats/2008-11-03-Invariant.ll create mode 100644 test/Transforms/LoopUnswitch/Stats/2011-11-18-SimpleSwitch.ll create mode 100644 test/Transforms/LoopUnswitch/Stats/2011-11-18-TwoSwitches-Threshold.ll create mode 100644 test/Transforms/LoopUnswitch/Stats/2011-11-18-TwoSwitches.ll create mode 100644 test/Transforms/LoopUnswitch/Stats/infinite-loop.ll create mode 100644 test/Transforms/LoopUnswitch/Stats/lit.local.cfg delete mode 100644 test/Transforms/LoopUnswitch/infinite-loop.ll (limited to 'test/Transforms/LoopUnswitch') diff --git a/test/Transforms/LoopUnswitch/2008-11-03-Invariant.ll b/test/Transforms/LoopUnswitch/2008-11-03-Invariant.ll deleted file mode 100644 index 9d73d31d50..0000000000 --- a/test/Transforms/LoopUnswitch/2008-11-03-Invariant.ll +++ /dev/null @@ -1,36 +0,0 @@ -; RUN: opt < %s -loop-unswitch -stats -disable-output 2>&1 | grep "1 loop-unswitch - Number of branches unswitched" | count 1 -; PR 3170 -define i32 @a(i32 %x, i32 %y) nounwind { -entry: - %0 = icmp ult i32 0, %y ; [#uses=1] - br i1 %0, label %bb.nph, label %bb4 - -bb.nph: ; preds = %entry - %1 = icmp eq i32 %x, 0 ; [#uses=1] - br label %bb - -bb: ; preds = %bb.nph, %bb3 - %i.01 = phi i32 [ %3, %bb3 ], [ 0, %bb.nph ] ; [#uses=1] - br i1 %1, label %bb2, label %bb1 - -bb1: ; preds = %bb - %2 = tail call i32 (...)* @b() nounwind ; [#uses=0] - br label %bb2 - -bb2: ; preds = %bb, %bb1 - %3 = add i32 %i.01, 1 ; [#uses=2] - br label %bb3 - -bb3: ; preds = %bb2 - %i.0 = phi i32 [ %3, %bb2 ] ; [#uses=1] - %4 = icmp ult i32 %i.0, %y ; [#uses=1] - br i1 %4, label %bb, label %bb3.bb4_crit_edge - -bb3.bb4_crit_edge: ; preds = %bb3 - br label %bb4 - -bb4: ; preds = %bb3.bb4_crit_edge, %entry - ret i32 0 -} - -declare i32 @b(...) diff --git a/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll b/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll deleted file mode 100644 index bde52da87a..0000000000 --- a/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll +++ /dev/null @@ -1,94 +0,0 @@ -; RUN: opt -loop-unswitch -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s -; RUN: opt -S -loop-unswitch -verify-loop-info -verify-dom-info < %s | FileCheck %s - -; STATS: 1 loop-simplify - Number of pre-header or exit blocks inserted -; STATS: 2 loop-unswitch - Number of switches unswitched - -; CHECK: %1 = icmp eq i32 %c, 1 -; CHECK-NEXT: br i1 %1, label %.split.us, label %..split_crit_edge - -; CHECK: ..split_crit_edge: ; preds = %0 -; CHECK-NEXT: br label %.split - -; CHECK: .split.us: ; preds = %0 -; CHECK-NEXT: br label %loop_begin.us - -; CHECK: loop_begin.us: ; preds = %loop_begin.backedge.us, %.split.us -; CHECK-NEXT: %var_val.us = load i32* %var -; CHECK-NEXT: switch i32 1, label %default.us-lcssa.us [ -; CHECK-NEXT: i32 1, label %inc.us - -; CHECK: inc.us: ; preds = %loop_begin.us -; CHECK-NEXT: call void @incf() [[NOR_NUW:#[0-9]+]] -; CHECK-NEXT: br label %loop_begin.backedge.us - -; CHECK: .split: ; preds = %..split_crit_edge -; CHECK-NEXT: %2 = icmp eq i32 %c, 2 -; CHECK-NEXT: br i1 %2, label %.split.split.us, label %.split..split.split_crit_edge - -; CHECK: .split..split.split_crit_edge: ; preds = %.split -; CHECK-NEXT: br label %.split.split - -; CHECK: .split.split.us: ; preds = %.split -; CHECK-NEXT: br label %loop_begin.us1 - -; CHECK: loop_begin.us1: ; preds = %loop_begin.backedge.us5, %.split.split.us -; CHECK-NEXT: %var_val.us2 = load i32* %var -; CHECK-NEXT: switch i32 2, label %default.us-lcssa.us-lcssa.us [ -; CHECK-NEXT: i32 1, label %inc.us4 -; CHECK-NEXT: i32 2, label %dec.us3 -; CHECK-NEXT: ] - -; CHECK: dec.us3: ; preds = %loop_begin.us1 -; CHECK-NEXT: call void @decf() [[NOR_NUW]] -; CHECK-NEXT: br label %loop_begin.backedge.us5 - -; CHECK: .split.split: ; preds = %.split..split.split_crit_edge -; CHECK-NEXT: br label %loop_begin - -; CHECK: loop_begin: ; preds = %loop_begin.backedge, %.split.split -; CHECK-NEXT: %var_val = load i32* %var -; CHECK-NEXT: switch i32 %c, label %default.us-lcssa.us-lcssa [ -; CHECK-NEXT: i32 1, label %inc -; CHECK-NEXT: i32 2, label %dec -; CHECK-NEXT: ] - -; CHECK: inc: ; preds = %loop_begin -; CHECK-NEXT: br i1 true, label %us-unreachable.us-lcssa, label %inc.split - -; CHECK: dec: ; preds = %loop_begin -; CHECK-NEXT: br i1 true, label %us-unreachable6, label %dec.split - -define i32 @test(i32* %var) { - %mem = alloca i32 - store i32 2, i32* %mem - %c = load i32* %mem - - br label %loop_begin - -loop_begin: - - %var_val = load i32* %var - - switch i32 %c, label %default [ - i32 1, label %inc - i32 2, label %dec - ] - -inc: - call void @incf() noreturn nounwind - br label %loop_begin -dec: - call void @decf() noreturn nounwind - br label %loop_begin -default: - br label %loop_exit -loop_exit: - ret i32 0 -} - -declare void @incf() noreturn -declare void @decf() noreturn - -; CHECK: attributes #0 = { noreturn } -; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } diff --git a/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll b/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll deleted file mode 100644 index c3bf5966ad..0000000000 --- a/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll +++ /dev/null @@ -1,87 +0,0 @@ -; RUN: opt -loop-unswitch -loop-unswitch-threshold 13 -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s -; RUN: opt -S -loop-unswitch -loop-unswitch-threshold 13 -verify-loop-info -verify-dom-info < %s | FileCheck %s - -; STATS: 1 loop-simplify - Number of pre-header or exit blocks inserted -; STATS: 1 loop-unswitch - Number of switches unswitched - -; ModuleID = '../llvm/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll' - -; CHECK: %1 = icmp eq i32 %c, 1 -; CHECK-NEXT: br i1 %1, label %.split.us, label %..split_crit_edge - -; CHECK: ..split_crit_edge: ; preds = %0 -; CHECK-NEXT: br label %.split - -; CHECK: .split.us: ; preds = %0 -; CHECK-NEXT: br label %loop_begin.us - -; CHECK: loop_begin.us: ; preds = %loop_begin.backedge.us, %.split.us -; CHECK: switch i32 1, label %second_switch.us [ -; CHECK-NEXT: i32 1, label %inc.us - -; CHECK: second_switch.us: ; preds = %loop_begin.us -; CHECK-NEXT: switch i32 %d, label %default.us [ -; CHECK-NEXT: i32 1, label %inc.us -; CHECK-NEXT: ] - -; CHECK: inc.us: ; preds = %second_switch.us, %loop_begin.us -; CHECK-NEXT: call void @incf() [[NOR_NUW:#[0-9]+]] -; CHECK-NEXT: br label %loop_begin.backedge.us - -; CHECK: .split: ; preds = %..split_crit_edge -; CHECK-NEXT: br label %loop_begin - -; CHECK: loop_begin: ; preds = %loop_begin.backedge, %.split -; CHECK: switch i32 %c, label %second_switch [ -; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge -; CHECK-NEXT: ] - -; CHECK: loop_begin.inc_crit_edge: ; preds = %loop_begin -; CHECK-NEXT: br i1 true, label %us-unreachable, label %inc - -; CHECK: second_switch: ; preds = %loop_begin -; CHECK-NEXT: switch i32 %d, label %default [ -; CHECK-NEXT: i32 1, label %inc -; CHECK-NEXT: ] - -; CHECK: inc: ; preds = %loop_begin.inc_crit_edge, %second_switch -; CHECK-NEXT: call void @incf() [[NOR_NUW]] -; CHECK-NEXT: br label %loop_begin.backedge - -define i32 @test(i32* %var) { - %mem = alloca i32 - store i32 2, i32* %mem - %c = load i32* %mem - %d = load i32* %mem - - br label %loop_begin - -loop_begin: - - %var_val = load i32* %var - - switch i32 %c, label %second_switch [ - i32 1, label %inc - ] - -second_switch: - switch i32 %d, label %default [ - i32 1, label %inc - ] - -inc: - call void @incf() noreturn nounwind - br label %loop_begin - -default: - br label %loop_begin - -loop_exit: - ret i32 0 -} - -declare void @incf() noreturn -declare void @decf() noreturn - -; CHECK: attributes #0 = { noreturn } -; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } diff --git a/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll b/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll deleted file mode 100644 index 95303337da..0000000000 --- a/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll +++ /dev/null @@ -1,141 +0,0 @@ -; RUN: opt -loop-unswitch -loop-unswitch-threshold 1000 -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s -; RUN: opt -S -loop-unswitch -loop-unswitch-threshold 1000 -verify-loop-info -verify-dom-info < %s | FileCheck %s - -; STATS: 1 loop-simplify - Number of pre-header or exit blocks inserted -; STATS: 3 loop-unswitch - Number of switches unswitched - -; CHECK: %1 = icmp eq i32 %c, 1 -; CHECK-NEXT: br i1 %1, label %.split.us, label %..split_crit_edge - -; CHECK: ..split_crit_edge: ; preds = %0 -; CHECK-NEXT: br label %.split - -; CHECK: .split.us: ; preds = %0 -; CHECK-NEXT: %2 = icmp eq i32 %d, 1 -; CHECK-NEXT: br i1 %2, label %.split.us.split.us, label %.split.us..split.us.split_crit_edge - -; CHECK: .split.us..split.us.split_crit_edge: ; preds = %.split.us -; CHECK-NEXT: br label %.split.us.split - -; CHECK: .split.us.split.us: ; preds = %.split.us -; CHECK-NEXT: br label %loop_begin.us.us - -; CHECK: loop_begin.us.us: ; preds = %loop_begin.backedge.us.us, %.split.us.split.us -; CHECK-NEXT: %var_val.us.us = load i32* %var -; CHECK-NEXT: switch i32 1, label %second_switch.us.us [ -; CHECK-NEXT: i32 1, label %inc.us.us - -; CHECK: second_switch.us.us: ; preds = %loop_begin.us.us -; CHECK-NEXT: switch i32 1, label %default.us.us [ -; CHECK-NEXT: i32 1, label %inc.us.us - -; CHECK: inc.us.us: ; preds = %second_switch.us.us, %loop_begin.us.us -; CHECK-NEXT: call void @incf() [[NOR_NUW:#[0-9]+]] -; CHECK-NEXT: br label %loop_begin.backedge.us.us - -; CHECK: .split.us.split: ; preds = %.split.us..split.us.split_crit_edge -; CHECK-NEXT: br label %loop_begin.us - -; CHECK: loop_begin.us: ; preds = %loop_begin.backedge.us, %.split.us.split -; CHECK-NEXT: %var_val.us = load i32* %var -; CHECK-NEXT: switch i32 1, label %second_switch.us [ -; CHECK-NEXT: i32 1, label %inc.us - -; CHECK: second_switch.us: ; preds = %loop_begin.us -; CHECK-NEXT: switch i32 %d, label %default.us [ -; CHECK-NEXT: i32 1, label %second_switch.us.inc.us_crit_edge -; CHECK-NEXT: ] - -; CHECK: second_switch.us.inc.us_crit_edge: ; preds = %second_switch.us -; CHECK-NEXT: br i1 true, label %us-unreachable8, label %inc.us - -; CHECK: inc.us: ; preds = %second_switch.us.inc.us_crit_edge, %loop_begin.us -; CHECK-NEXT: call void @incf() [[NOR_NUW]] -; CHECK-NEXT: br label %loop_begin.backedge.us - -; CHECK: .split: ; preds = %..split_crit_edge -; CHECK-NEXT: %3 = icmp eq i32 %d, 1 -; CHECK-NEXT: br i1 %3, label %.split.split.us, label %.split..split.split_crit_edge - -; CHECK: .split..split.split_crit_edge: ; preds = %.split -; CHECK-NEXT: br label %.split.split - -; CHECK: .split.split.us: ; preds = %.split -; CHECK-NEXT: br label %loop_begin.us1 - -; CHECK: loop_begin.us1: ; preds = %loop_begin.backedge.us6, %.split.split.us -; CHECK-NEXT: %var_val.us2 = load i32* %var -; CHECK-NEXT: switch i32 %c, label %second_switch.us3 [ -; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge.us -; CHECK-NEXT: ] - -; CHECK: second_switch.us3: ; preds = %loop_begin.us1 -; CHECK-NEXT: switch i32 1, label %default.us5 [ -; CHECK-NEXT: i32 1, label %inc.us4 -; CHECK-NEXT: ] - -; CHECK: inc.us4: ; preds = %loop_begin.inc_crit_edge.us, %second_switch.us3 -; CHECK-NEXT: call void @incf() [[NOR_NUW]] -; CHECK-NEXT: br label %loop_begin.backedge.us6 - -; CHECK: loop_begin.inc_crit_edge.us: ; preds = %loop_begin.us1 -; CHECK-NEXT: br i1 true, label %us-unreachable.us-lcssa.us, label %inc.us4 - -; CHECK: .split.split: ; preds = %.split..split.split_crit_edge -; CHECK-NEXT: br label %loop_begin - -; CHECK: loop_begin: ; preds = %loop_begin.backedge, %.split.split -; CHECK-NEXT: %var_val = load i32* %var -; CHECK-NEXT: switch i32 %c, label %second_switch [ -; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge -; CHECK-NEXT: ] - -; CHECK: loop_begin.inc_crit_edge: ; preds = %loop_begin -; CHECK-NEXT: br i1 true, label %us-unreachable.us-lcssa, label %inc - -; CHECK: second_switch: ; preds = %loop_begin -; CHECK-NEXT: switch i32 %d, label %default [ -; CHECK-NEXT: i32 1, label %second_switch.inc_crit_edge -; CHECK-NEXT: ] - -; CHECK: second_switch.inc_crit_edge: ; preds = %second_switch -; CHECK-NEXT: br i1 true, label %us-unreachable7, label %inc - - -define i32 @test(i32* %var) { - %mem = alloca i32 - store i32 2, i32* %mem - %c = load i32* %mem - %d = load i32* %mem - - br label %loop_begin - -loop_begin: - - %var_val = load i32* %var - - switch i32 %c, label %second_switch [ - i32 1, label %inc - ] - -second_switch: - switch i32 %d, label %default [ - i32 1, label %inc - ] - -inc: - call void @incf() noreturn nounwind - br label %loop_begin - -default: - br label %loop_begin - -loop_exit: - ret i32 0 -} - -declare void @incf() noreturn -declare void @decf() noreturn - -; CHECK: attributes #0 = { noreturn } -; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } diff --git a/test/Transforms/LoopUnswitch/Stats/2008-11-03-Invariant.ll b/test/Transforms/LoopUnswitch/Stats/2008-11-03-Invariant.ll new file mode 100644 index 0000000000..9d73d31d50 --- /dev/null +++ b/test/Transforms/LoopUnswitch/Stats/2008-11-03-Invariant.ll @@ -0,0 +1,36 @@ +; RUN: opt < %s -loop-unswitch -stats -disable-output 2>&1 | grep "1 loop-unswitch - Number of branches unswitched" | count 1 +; PR 3170 +define i32 @a(i32 %x, i32 %y) nounwind { +entry: + %0 = icmp ult i32 0, %y ; [#uses=1] + br i1 %0, label %bb.nph, label %bb4 + +bb.nph: ; preds = %entry + %1 = icmp eq i32 %x, 0 ; [#uses=1] + br label %bb + +bb: ; preds = %bb.nph, %bb3 + %i.01 = phi i32 [ %3, %bb3 ], [ 0, %bb.nph ] ; [#uses=1] + br i1 %1, label %bb2, label %bb1 + +bb1: ; preds = %bb + %2 = tail call i32 (...)* @b() nounwind ; [#uses=0] + br label %bb2 + +bb2: ; preds = %bb, %bb1 + %3 = add i32 %i.01, 1 ; [#uses=2] + br label %bb3 + +bb3: ; preds = %bb2 + %i.0 = phi i32 [ %3, %bb2 ] ; [#uses=1] + %4 = icmp ult i32 %i.0, %y ; [#uses=1] + br i1 %4, label %bb, label %bb3.bb4_crit_edge + +bb3.bb4_crit_edge: ; preds = %bb3 + br label %bb4 + +bb4: ; preds = %bb3.bb4_crit_edge, %entry + ret i32 0 +} + +declare i32 @b(...) diff --git a/test/Transforms/LoopUnswitch/Stats/2011-11-18-SimpleSwitch.ll b/test/Transforms/LoopUnswitch/Stats/2011-11-18-SimpleSwitch.ll new file mode 100644 index 0000000000..bde52da87a --- /dev/null +++ b/test/Transforms/LoopUnswitch/Stats/2011-11-18-SimpleSwitch.ll @@ -0,0 +1,94 @@ +; RUN: opt -loop-unswitch -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s +; RUN: opt -S -loop-unswitch -verify-loop-info -verify-dom-info < %s | FileCheck %s + +; STATS: 1 loop-simplify - Number of pre-header or exit blocks inserted +; STATS: 2 loop-unswitch - Number of switches unswitched + +; CHECK: %1 = icmp eq i32 %c, 1 +; CHECK-NEXT: br i1 %1, label %.split.us, label %..split_crit_edge + +; CHECK: ..split_crit_edge: ; preds = %0 +; CHECK-NEXT: br label %.split + +; CHECK: .split.us: ; preds = %0 +; CHECK-NEXT: br label %loop_begin.us + +; CHECK: loop_begin.us: ; preds = %loop_begin.backedge.us, %.split.us +; CHECK-NEXT: %var_val.us = load i32* %var +; CHECK-NEXT: switch i32 1, label %default.us-lcssa.us [ +; CHECK-NEXT: i32 1, label %inc.us + +; CHECK: inc.us: ; preds = %loop_begin.us +; CHECK-NEXT: call void @incf() [[NOR_NUW:#[0-9]+]] +; CHECK-NEXT: br label %loop_begin.backedge.us + +; CHECK: .split: ; preds = %..split_crit_edge +; CHECK-NEXT: %2 = icmp eq i32 %c, 2 +; CHECK-NEXT: br i1 %2, label %.split.split.us, label %.split..split.split_crit_edge + +; CHECK: .split..split.split_crit_edge: ; preds = %.split +; CHECK-NEXT: br label %.split.split + +; CHECK: .split.split.us: ; preds = %.split +; CHECK-NEXT: br label %loop_begin.us1 + +; CHECK: loop_begin.us1: ; preds = %loop_begin.backedge.us5, %.split.split.us +; CHECK-NEXT: %var_val.us2 = load i32* %var +; CHECK-NEXT: switch i32 2, label %default.us-lcssa.us-lcssa.us [ +; CHECK-NEXT: i32 1, label %inc.us4 +; CHECK-NEXT: i32 2, label %dec.us3 +; CHECK-NEXT: ] + +; CHECK: dec.us3: ; preds = %loop_begin.us1 +; CHECK-NEXT: call void @decf() [[NOR_NUW]] +; CHECK-NEXT: br label %loop_begin.backedge.us5 + +; CHECK: .split.split: ; preds = %.split..split.split_crit_edge +; CHECK-NEXT: br label %loop_begin + +; CHECK: loop_begin: ; preds = %loop_begin.backedge, %.split.split +; CHECK-NEXT: %var_val = load i32* %var +; CHECK-NEXT: switch i32 %c, label %default.us-lcssa.us-lcssa [ +; CHECK-NEXT: i32 1, label %inc +; CHECK-NEXT: i32 2, label %dec +; CHECK-NEXT: ] + +; CHECK: inc: ; preds = %loop_begin +; CHECK-NEXT: br i1 true, label %us-unreachable.us-lcssa, label %inc.split + +; CHECK: dec: ; preds = %loop_begin +; CHECK-NEXT: br i1 true, label %us-unreachable6, label %dec.split + +define i32 @test(i32* %var) { + %mem = alloca i32 + store i32 2, i32* %mem + %c = load i32* %mem + + br label %loop_begin + +loop_begin: + + %var_val = load i32* %var + + switch i32 %c, label %default [ + i32 1, label %inc + i32 2, label %dec + ] + +inc: + call void @incf() noreturn nounwind + br label %loop_begin +dec: + call void @decf() noreturn nounwind + br label %loop_begin +default: + br label %loop_exit +loop_exit: + ret i32 0 +} + +declare void @incf() noreturn +declare void @decf() noreturn + +; CHECK: attributes #0 = { noreturn } +; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } diff --git a/test/Transforms/LoopUnswitch/Stats/2011-11-18-TwoSwitches-Threshold.ll b/test/Transforms/LoopUnswitch/Stats/2011-11-18-TwoSwitches-Threshold.ll new file mode 100644 index 0000000000..c3bf5966ad --- /dev/null +++ b/test/Transforms/LoopUnswitch/Stats/2011-11-18-TwoSwitches-Threshold.ll @@ -0,0 +1,87 @@ +; RUN: opt -loop-unswitch -loop-unswitch-threshold 13 -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s +; RUN: opt -S -loop-unswitch -loop-unswitch-threshold 13 -verify-loop-info -verify-dom-info < %s | FileCheck %s + +; STATS: 1 loop-simplify - Number of pre-header or exit blocks inserted +; STATS: 1 loop-unswitch - Number of switches unswitched + +; ModuleID = '../llvm/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll' + +; CHECK: %1 = icmp eq i32 %c, 1 +; CHECK-NEXT: br i1 %1, label %.split.us, label %..split_crit_edge + +; CHECK: ..split_crit_edge: ; preds = %0 +; CHECK-NEXT: br label %.split + +; CHECK: .split.us: ; preds = %0 +; CHECK-NEXT: br label %loop_begin.us + +; CHECK: loop_begin.us: ; preds = %loop_begin.backedge.us, %.split.us +; CHECK: switch i32 1, label %second_switch.us [ +; CHECK-NEXT: i32 1, label %inc.us + +; CHECK: second_switch.us: ; preds = %loop_begin.us +; CHECK-NEXT: switch i32 %d, label %default.us [ +; CHECK-NEXT: i32 1, label %inc.us +; CHECK-NEXT: ] + +; CHECK: inc.us: ; preds = %second_switch.us, %loop_begin.us +; CHECK-NEXT: call void @incf() [[NOR_NUW:#[0-9]+]] +; CHECK-NEXT: br label %loop_begin.backedge.us + +; CHECK: .split: ; preds = %..split_crit_edge +; CHECK-NEXT: br label %loop_begin + +; CHECK: loop_begin: ; preds = %loop_begin.backedge, %.split +; CHECK: switch i32 %c, label %second_switch [ +; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge +; CHECK-NEXT: ] + +; CHECK: loop_begin.inc_crit_edge: ; preds = %loop_begin +; CHECK-NEXT: br i1 true, label %us-unreachable, label %inc + +; CHECK: second_switch: ; preds = %loop_begin +; CHECK-NEXT: switch i32 %d, label %default [ +; CHECK-NEXT: i32 1, label %inc +; CHECK-NEXT: ] + +; CHECK: inc: ; preds = %loop_begin.inc_crit_edge, %second_switch +; CHECK-NEXT: call void @incf() [[NOR_NUW]] +; CHECK-NEXT: br label %loop_begin.backedge + +define i32 @test(i32* %var) { + %mem = alloca i32 + store i32 2, i32* %mem + %c = load i32* %mem + %d = load i32* %mem + + br label %loop_begin + +loop_begin: + + %var_val = load i32* %var + + switch i32 %c, label %second_switch [ + i32 1, label %inc + ] + +second_switch: + switch i32 %d, label %default [ + i32 1, label %inc + ] + +inc: + call void @incf() noreturn nounwind + br label %loop_begin + +default: + br label %loop_begin + +loop_exit: + ret i32 0 +} + +declare void @incf() noreturn +declare void @decf() noreturn + +; CHECK: attributes #0 = { noreturn } +; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } diff --git a/test/Transforms/LoopUnswitch/Stats/2011-11-18-TwoSwitches.ll b/test/Transforms/LoopUnswitch/Stats/2011-11-18-TwoSwitches.ll new file mode 100644 index 0000000000..95303337da --- /dev/null +++ b/test/Transforms/LoopUnswitch/Stats/2011-11-18-TwoSwitches.ll @@ -0,0 +1,141 @@ +; RUN: opt -loop-unswitch -loop-unswitch-threshold 1000 -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s +; RUN: opt -S -loop-unswitch -loop-unswitch-threshold 1000 -verify-loop-info -verify-dom-info < %s | FileCheck %s + +; STATS: 1 loop-simplify - Number of pre-header or exit blocks inserted +; STATS: 3 loop-unswitch - Number of switches unswitched + +; CHECK: %1 = icmp eq i32 %c, 1 +; CHECK-NEXT: br i1 %1, label %.split.us, label %..split_crit_edge + +; CHECK: ..split_crit_edge: ; preds = %0 +; CHECK-NEXT: br label %.split + +; CHECK: .split.us: ; preds = %0 +; CHECK-NEXT: %2 = icmp eq i32 %d, 1 +; CHECK-NEXT: br i1 %2, label %.split.us.split.us, label %.split.us..split.us.split_crit_edge + +; CHECK: .split.us..split.us.split_crit_edge: ; preds = %.split.us +; CHECK-NEXT: br label %.split.us.split + +; CHECK: .split.us.split.us: ; preds = %.split.us +; CHECK-NEXT: br label %loop_begin.us.us + +; CHECK: loop_begin.us.us: ; preds = %loop_begin.backedge.us.us, %.split.us.split.us +; CHECK-NEXT: %var_val.us.us = load i32* %var +; CHECK-NEXT: switch i32 1, label %second_switch.us.us [ +; CHECK-NEXT: i32 1, label %inc.us.us + +; CHECK: second_switch.us.us: ; preds = %loop_begin.us.us +; CHECK-NEXT: switch i32 1, label %default.us.us [ +; CHECK-NEXT: i32 1, label %inc.us.us + +; CHECK: inc.us.us: ; preds = %second_switch.us.us, %loop_begin.us.us +; CHECK-NEXT: call void @incf() [[NOR_NUW:#[0-9]+]] +; CHECK-NEXT: br label %loop_begin.backedge.us.us + +; CHECK: .split.us.split: ; preds = %.split.us..split.us.split_crit_edge +; CHECK-NEXT: br label %loop_begin.us + +; CHECK: loop_begin.us: ; preds = %loop_begin.backedge.us, %.split.us.split +; CHECK-NEXT: %var_val.us = load i32* %var +; CHECK-NEXT: switch i32 1, label %second_switch.us [ +; CHECK-NEXT: i32 1, label %inc.us + +; CHECK: second_switch.us: ; preds = %loop_begin.us +; CHECK-NEXT: switch i32 %d, label %default.us [ +; CHECK-NEXT: i32 1, label %second_switch.us.inc.us_crit_edge +; CHECK-NEXT: ] + +; CHECK: second_switch.us.inc.us_crit_edge: ; preds = %second_switch.us +; CHECK-NEXT: br i1 true, label %us-unreachable8, label %inc.us + +; CHECK: inc.us: ; preds = %second_switch.us.inc.us_crit_edge, %loop_begin.us +; CHECK-NEXT: call void @incf() [[NOR_NUW]] +; CHECK-NEXT: br label %loop_begin.backedge.us + +; CHECK: .split: ; preds = %..split_crit_edge +; CHECK-NEXT: %3 = icmp eq i32 %d, 1 +; CHECK-NEXT: br i1 %3, label %.split.split.us, label %.split..split.split_crit_edge + +; CHECK: .split..split.split_crit_edge: ; preds = %.split +; CHECK-NEXT: br label %.split.split + +; CHECK: .split.split.us: ; preds = %.split +; CHECK-NEXT: br label %loop_begin.us1 + +; CHECK: loop_begin.us1: ; preds = %loop_begin.backedge.us6, %.split.split.us +; CHECK-NEXT: %var_val.us2 = load i32* %var +; CHECK-NEXT: switch i32 %c, label %second_switch.us3 [ +; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge.us +; CHECK-NEXT: ] + +; CHECK: second_switch.us3: ; preds = %loop_begin.us1 +; CHECK-NEXT: switch i32 1, label %default.us5 [ +; CHECK-NEXT: i32 1, label %inc.us4 +; CHECK-NEXT: ] + +; CHECK: inc.us4: ; preds = %loop_begin.inc_crit_edge.us, %second_switch.us3 +; CHECK-NEXT: call void @incf() [[NOR_NUW]] +; CHECK-NEXT: br label %loop_begin.backedge.us6 + +; CHECK: loop_begin.inc_crit_edge.us: ; preds = %loop_begin.us1 +; CHECK-NEXT: br i1 true, label %us-unreachable.us-lcssa.us, label %inc.us4 + +; CHECK: .split.split: ; preds = %.split..split.split_crit_edge +; CHECK-NEXT: br label %loop_begin + +; CHECK: loop_begin: ; preds = %loop_begin.backedge, %.split.split +; CHECK-NEXT: %var_val = load i32* %var +; CHECK-NEXT: switch i32 %c, label %second_switch [ +; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge +; CHECK-NEXT: ] + +; CHECK: loop_begin.inc_crit_edge: ; preds = %loop_begin +; CHECK-NEXT: br i1 true, label %us-unreachable.us-lcssa, label %inc + +; CHECK: second_switch: ; preds = %loop_begin +; CHECK-NEXT: switch i32 %d, label %default [ +; CHECK-NEXT: i32 1, label %second_switch.inc_crit_edge +; CHECK-NEXT: ] + +; CHECK: second_switch.inc_crit_edge: ; preds = %second_switch +; CHECK-NEXT: br i1 true, label %us-unreachable7, label %inc + + +define i32 @test(i32* %var) { + %mem = alloca i32 + store i32 2, i32* %mem + %c = load i32* %mem + %d = load i32* %mem + + br label %loop_begin + +loop_begin: + + %var_val = load i32* %var + + switch i32 %c, label %second_switch [ + i32 1, label %inc + ] + +second_switch: + switch i32 %d, label %default [ + i32 1, label %inc + ] + +inc: + call void @incf() noreturn nounwind + br label %loop_begin + +default: + br label %loop_begin + +loop_exit: + ret i32 0 +} + +declare void @incf() noreturn +declare void @decf() noreturn + +; CHECK: attributes #0 = { noreturn } +; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } diff --git a/test/Transforms/LoopUnswitch/Stats/infinite-loop.ll b/test/Transforms/LoopUnswitch/Stats/infinite-loop.ll new file mode 100644 index 0000000000..f3fba642f8 --- /dev/null +++ b/test/Transforms/LoopUnswitch/Stats/infinite-loop.ll @@ -0,0 +1,57 @@ +; RUN: opt -loop-unswitch -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s +; RUN: opt -loop-unswitch -simplifycfg -S < %s | FileCheck %s +; PR5373 + +; Loop unswitching shouldn't trivially unswitch the true case of condition %a +; in the code here because it leads to an infinite loop. While this doesn't +; contain any instructions with side effects, it's still a kind of side effect. +; It can trivially unswitch on the false cas of condition %a though. + +; STATS: 2 loop-unswitch - Number of branches unswitched +; STATS: 1 loop-unswitch - Number of unswitches that are trivial + +; CHECK: @func_16 +; CHECK-NEXT: entry: +; CHECK-NEXT: br i1 %a, label %entry.split, label %abort0.split + +; CHECK: entry.split: +; CHECK-NEXT: br i1 %b, label %cond.end.us, label %abort1 + +; CHECK: cond.end.us: +; CHECK-NEXT: br label %cond.end.us + +; CHECK: abort0.split: +; CHECK-NEXT: call void @end0() [[NOR_NUW:#[0-9]+]] +; CHECK-NEXT: unreachable + +; CHECK: abort1: +; CHECK-NEXT: call void @end1() [[NOR_NUW]] +; CHECK-NEXT: unreachable + +; CHECK: } + +define void @func_16(i1 %a, i1 %b) nounwind { +entry: + br label %for.body + +for.body: + br i1 %a, label %cond.end, label %abort0 + +cond.end: + br i1 %b, label %for.body, label %abort1 + +abort0: + call void @end0() noreturn nounwind + unreachable + +abort1: + call void @end1() noreturn nounwind + unreachable +} + +declare void @end0() noreturn +declare void @end1() noreturn + +; CHECK: attributes #0 = { nounwind } +; CHECK: attributes #1 = { noreturn } +; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } diff --git a/test/Transforms/LoopUnswitch/Stats/lit.local.cfg b/test/Transforms/LoopUnswitch/Stats/lit.local.cfg new file mode 100644 index 0000000000..89c0cd9d48 --- /dev/null +++ b/test/Transforms/LoopUnswitch/Stats/lit.local.cfg @@ -0,0 +1,4 @@ +config.suffixes = ['.ll', '.c', '.cpp'] + +if not config.root.enable_assertions: + config.unsupported = True diff --git a/test/Transforms/LoopUnswitch/infinite-loop.ll b/test/Transforms/LoopUnswitch/infinite-loop.ll deleted file mode 100644 index f3fba642f8..0000000000 --- a/test/Transforms/LoopUnswitch/infinite-loop.ll +++ /dev/null @@ -1,57 +0,0 @@ -; RUN: opt -loop-unswitch -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s -; RUN: opt -loop-unswitch -simplifycfg -S < %s | FileCheck %s -; PR5373 - -; Loop unswitching shouldn't trivially unswitch the true case of condition %a -; in the code here because it leads to an infinite loop. While this doesn't -; contain any instructions with side effects, it's still a kind of side effect. -; It can trivially unswitch on the false cas of condition %a though. - -; STATS: 2 loop-unswitch - Number of branches unswitched -; STATS: 1 loop-unswitch - Number of unswitches that are trivial - -; CHECK: @func_16 -; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 %a, label %entry.split, label %abort0.split - -; CHECK: entry.split: -; CHECK-NEXT: br i1 %b, label %cond.end.us, label %abort1 - -; CHECK: cond.end.us: -; CHECK-NEXT: br label %cond.end.us - -; CHECK: abort0.split: -; CHECK-NEXT: call void @end0() [[NOR_NUW:#[0-9]+]] -; CHECK-NEXT: unreachable - -; CHECK: abort1: -; CHECK-NEXT: call void @end1() [[NOR_NUW]] -; CHECK-NEXT: unreachable - -; CHECK: } - -define void @func_16(i1 %a, i1 %b) nounwind { -entry: - br label %for.body - -for.body: - br i1 %a, label %cond.end, label %abort0 - -cond.end: - br i1 %b, label %for.body, label %abort1 - -abort0: - call void @end0() noreturn nounwind - unreachable - -abort1: - call void @end1() noreturn nounwind - unreachable -} - -declare void @end0() noreturn -declare void @end1() noreturn - -; CHECK: attributes #0 = { nounwind } -; CHECK: attributes #1 = { noreturn } -; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } -- cgit v1.2.3-70-g09d2