diff options
author | Jingyue Wu <jingyue@google.com> | 2015-08-31 06:10:27 +0000 |
---|---|---|
committer | Jingyue Wu <jingyue@google.com> | 2015-08-31 06:10:27 +0000 |
commit | e84f6718300d8842b71b56c6593cff3f91d69323 (patch) | |
tree | df48c1c23342d5d77e4d56a88ed4cd850826b0be /llvm/lib/Transforms | |
parent | 64c0ff414109082f14060f318794398e7bc65bde (diff) | |
download | bcm5719-llvm-e84f6718300d8842b71b56c6593cff3f91d69323.tar.gz bcm5719-llvm-e84f6718300d8842b71b56c6593cff3f91d69323.zip |
[JumpThreading] make jump threading respect convergent annotation.
Summary:
JumpThreading shouldn't duplicate a convergent call, because that would move a convergent call into a control-inequivalent location. For example,
if (cond) {
...
} else {
...
}
convergent_call();
if (cond) {
...
} else {
...
}
should not be optimized to
if (cond) {
...
convergent_call();
...
} else {
...
convergent_call();
...
}
Test Plan: test/Transforms/JumpThreading/basic.ll
Patch by Xuetian Weng.
Reviewers: resistor, arsenm, jingyue
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D12484
llvm-svn: 246415
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index b87f4766e8d..2d5aef88470 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -273,7 +273,7 @@ static unsigned getJumpThreadDuplicationCost(const BasicBlock *BB, // as having cost of 2 total, and if they are a vector intrinsic, we model // them as having cost 1. if (const CallInst *CI = dyn_cast<CallInst>(I)) { - if (CI->cannotDuplicate()) + if (CI->cannotDuplicate() || CI->isConvergent()) // Blocks with NoDuplicate are modelled as having infinite cost, so they // are never duplicated. return ~0U; |