diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2018-04-19 18:44:25 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2018-04-19 18:44:25 +0000 |
commit | 32e62f9c5b85d481afbe277ecdb65476372b3411 (patch) | |
tree | b83deb1fedad497e993029b6c918b3f9f52ae33b /llvm/test/Transforms/SimpleLoopUnswitch | |
parent | 9bbd653084de43b3d1d80fec157798bc0d557598 (diff) | |
download | bcm5719-llvm-32e62f9c5b85d481afbe277ecdb65476372b3411.tar.gz bcm5719-llvm-32e62f9c5b85d481afbe277ecdb65476372b3411.zip |
[PM/LoopUnswitch] Detect irreducible control flow within loops and skip unswitching non-trivial edges.
Summary:
This fixes the bug pointed out in review with non-trivial unswitching.
This also provides a basis that should make it pretty easy to finish
fleshing out a routine to scan an entire function body for irreducible
control flow, but this patch remains minimal for disabling loop
unswitch.
Reviewers: sanjoy, fedor.sergeev
Subscribers: mcrosier, hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D45754
llvm-svn: 330357
Diffstat (limited to 'llvm/test/Transforms/SimpleLoopUnswitch')
-rw-r--r-- | llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll b/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll index 51cdebe70e0..651ba19c427 100644 --- a/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll +++ b/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll @@ -2350,3 +2350,33 @@ loop_exit: ; CHECK-NEXT: %[[LCSSA:.*]] = phi i32 [ %[[V]], %loop_begin ] ; CHECK-NEXT: ret i32 %[[LCSSA]] } + +; Negative test: we do not switch when the loop contains unstructured control +; flows as it would significantly complicate the process as novel loops might +; be formed, etc. +define void @test_no_unswitch_unstructured_cfg(i1* %ptr, i1 %cond) { +; CHECK-LABEL: @test_no_unswitch_unstructured_cfg( +entry: + br label %loop_begin + +loop_begin: + br i1 %cond, label %loop_left, label %loop_right + +loop_left: + %v1 = load i1, i1* %ptr + br i1 %v1, label %loop_right, label %loop_merge + +loop_right: + %v2 = load i1, i1* %ptr + br i1 %v2, label %loop_left, label %loop_merge + +loop_merge: + %v3 = load i1, i1* %ptr + br i1 %v3, label %loop_latch, label %loop_exit + +loop_latch: + br label %loop_begin + +loop_exit: + ret void +} |