summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2019-05-29 20:47:59 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2019-05-29 20:47:59 +0000
commit79b3ea701c8be993e11ea211ad35be2d178f5a08 (patch)
treea50fa0c5c1c9766eeb65db23414ac4d09c08e640 /llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
parent74c5fac3bba77d796132c313b77c808b2165b75d (diff)
downloadbcm5719-llvm-79b3ea701c8be993e11ea211ad35be2d178f5a08.tar.gz
bcm5719-llvm-79b3ea701c8be993e11ea211ad35be2d178f5a08.zip
LoopVersioningLICM: Respect convergent and noduplicate
llvm-svn: 362031
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
index 87898df5ec1..896dd8bcb92 100644
--- a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
@@ -356,14 +356,22 @@ bool LoopVersioningLICM::legalLoopMemoryAccesses() {
/// 1) Check all load store in loop body are non atomic & non volatile.
/// 2) Check function call safety, by ensuring its not accessing memory.
/// 3) Loop body shouldn't have any may throw instruction.
+/// 4) Loop body shouldn't have any convergent or noduplicate instructions.
bool LoopVersioningLICM::instructionSafeForVersioning(Instruction *I) {
assert(I != nullptr && "Null instruction found!");
// Check function call safety
- if (auto *Call = dyn_cast<CallBase>(I))
+ if (auto *Call = dyn_cast<CallBase>(I)) {
+ if (Call->isConvergent() || Call->cannotDuplicate()) {
+ LLVM_DEBUG(dbgs() << " Convergent call site found.\n");
+ return false;
+ }
+
if (!AA->doesNotAccessMemory(Call)) {
LLVM_DEBUG(dbgs() << " Unsafe call site found.\n");
return false;
}
+ }
+
// Avoid loops with possiblity of throw
if (I->mayThrow()) {
LLVM_DEBUG(dbgs() << " May throw instruction found in loop body\n");
OpenPOWER on IntegriCloud