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/lib/Transforms/Scalar/LoopUnswitch.cpp | |
parent | dbd02a40d2fc8955d4c2c3069f8f1be4a5016772 (diff) | |
download | llvm-2c9978b12b08c08da94347cc2b120b8affaa53dc.zip llvm-2c9978b12b08c08da94347cc2b120b8affaa53dc.tar.gz llvm-2c9978b12b08c08da94347cc2b120b8affaa53dc.tar.bz2 |
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/lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp index 60910ba..6d99caf 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -500,6 +500,20 @@ bool LoopUnswitch::processCurrentLoop() { return true; } + // Do not unswitch loops containing convergent operations, as we might be + // making them control dependent on the unswitch value when they were not + // before. + // FIXME: This could be refined to only bail if the convergent operation is + // not already control-dependent on the unswitch value. + for (const auto BB : currentLoop->blocks()) { + for (const auto &I : *BB) { + const auto CI = dyn_cast<CallInst>(&I); + if (!CI) continue; + if (CI->isConvergent()) + return false; + } + } + // Do not do non-trivial unswitch while optimizing for size. // FIXME: Use Function::optForSize(). if (OptimizeForSize || |