diff options
author | Sebastian Pop <sebpop@gmail.com> | 2016-07-22 00:07:01 +0000 |
---|---|---|
committer | Sebastian Pop <sebpop@gmail.com> | 2016-07-22 00:07:01 +0000 |
commit | 0e2cec075c98fe33623229dcb6ee6275f2897de4 (patch) | |
tree | b3058f936e95ba86e7dfa8e1fd483dace11a7173 /llvm/lib/Transforms/Scalar/GVNHoist.cpp | |
parent | fe28a0fdd532bc058aafdf2a2bc6b93600c46434 (diff) | |
download | bcm5719-llvm-0e2cec075c98fe33623229dcb6ee6275f2897de4.tar.gz bcm5719-llvm-0e2cec075c98fe33623229dcb6ee6275f2897de4.zip |
GVN-hoist: move check before mutating the IR
llvm-svn: 276368
Diffstat (limited to 'llvm/lib/Transforms/Scalar/GVNHoist.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/GVNHoist.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp index c420089cc6d..e7179a342c2 100644 --- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -585,9 +585,14 @@ public: Gep = dyn_cast<GetElementPtrInst>(St->getPointerOperand()); Val = dyn_cast<Instruction>(St->getValueOperand()); // Check that the stored value is available. - if (Val && !isa<GetElementPtrInst>(Val) && - !DT->dominates(Val->getParent(), HoistPt)) - return false; + if (Val) { + if (isa<GetElementPtrInst>(Val)) { + // Check whether we can compute the GEP at HoistPt. + if (!allOperandsAvailable(Val, HoistPt)) + return false; + } else if (!DT->dominates(Val->getParent(), HoistPt)) + return false; + } } // Check whether we can compute the Gep at HoistPt. @@ -613,9 +618,6 @@ public: // Also copy Val when it is a GEP. if (Val && isa<GetElementPtrInst>(Val)) { - // Check whether we can compute the GEP at HoistPt. - if (!allOperandsAvailable(Val, HoistPt)) - return false; Instruction *ClonedVal = Val->clone(); ClonedVal->insertBefore(HoistPt->getTerminator()); // Conservatively discard any optimization hints, they may differ on the |