mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-20 19:42:54 +02:00
GVN-hoist: move check before mutating the IR
llvm-svn: 276368
This commit is contained in:
parent
fbccf1a76d
commit
cbfc347897
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user