diff options
author | Owen Anderson <resistor@mac.com> | 2015-10-09 18:40:20 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2015-10-09 18:40:20 +0000 |
commit | 2c9978b12b08c08da94347cc2b120b8affaa53dc (patch) | |
tree | 8a8f6f1fa66a67119ed8ba14d4b419c1bac8b9da /llvm/test/Transforms/LoopUnswitch/basictest.ll | |
parent | dbd02a40d2fc8955d4c2c3069f8f1be4a5016772 (diff) | |
download | bcm5719-llvm-2c9978b12b08c08da94347cc2b120b8affaa53dc.tar.gz bcm5719-llvm-2c9978b12b08c08da94347cc2b120b8affaa53dc.zip |
Teach LoopUnswitch not to perform non-trivial unswitching on loops containing convergent operations.
Doing so could cause the post-unswitching convergent ops to be
control-dependent on the unswitch condition where they were not before.
This check could be refined to allow unswitching where the convergent
operation was already control-dependent on the unswitch condition.
llvm-svn: 249874
Diffstat (limited to 'llvm/test/Transforms/LoopUnswitch/basictest.ll')
-rw-r--r-- | llvm/test/Transforms/LoopUnswitch/basictest.ll | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LoopUnswitch/basictest.ll b/llvm/test/Transforms/LoopUnswitch/basictest.ll index e990144d5cc..a02a463764d 100644 --- a/llvm/test/Transforms/LoopUnswitch/basictest.ll +++ b/llvm/test/Transforms/LoopUnswitch/basictest.ll @@ -64,5 +64,44 @@ loop_exit: ; CHECK: } } +; This simple test would normally unswitch, but should be inhibited by the presence of +; the convergent call that is not control-dependent on the unswitch condition. + +; CHECK-LABEL: @test3( +define i32 @test3(i32* %var) { + %mem = alloca i32 + store i32 2, i32* %mem + %c = load i32, i32* %mem + + br label %loop_begin + +loop_begin: + + %var_val = load i32, i32* %var + +; CHECK: call void @conv() +; CHECK-NOT: call void @conv() + call void @conv() convergent + + 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 +; CHECK: } +} + + declare void @incf() noreturn declare void @decf() noreturn +declare void @conv() convergent |