mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
Enhance hasConstantValue to ignore undef values in phi nodes. This allows it
to think that PHI[4, undef] == 4. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17096 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c30bda7540
commit
8143c2bc0d
@ -353,7 +353,8 @@ Value *llvm::hasConstantValue(PHINode *PN) {
|
|||||||
//
|
//
|
||||||
Value *InVal = 0;
|
Value *InVal = 0;
|
||||||
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
||||||
if (PN->getIncomingValue(i) != PN) // Not the PHI node itself...
|
if (PN->getIncomingValue(i) != PN && // Not the PHI node itself...
|
||||||
|
!isa<UndefValue>(PN->getIncomingValue(i)))
|
||||||
if (InVal && PN->getIncomingValue(i) != InVal)
|
if (InVal && PN->getIncomingValue(i) != InVal)
|
||||||
return 0; // Not the same, bail out.
|
return 0; // Not the same, bail out.
|
||||||
else
|
else
|
||||||
@ -363,7 +364,7 @@ Value *llvm::hasConstantValue(PHINode *PN) {
|
|||||||
// that only has entries for itself. In this case, there is no entry into the
|
// that only has entries for itself. In this case, there is no entry into the
|
||||||
// loop, so kill the PHI.
|
// loop, so kill the PHI.
|
||||||
//
|
//
|
||||||
if (InVal == 0) InVal = Constant::getNullValue(PN->getType());
|
if (InVal == 0) InVal = UndefValue::get(PN->getType());
|
||||||
|
|
||||||
// All of the incoming values are the same, return the value now.
|
// All of the incoming values are the same, return the value now.
|
||||||
return InVal;
|
return InVal;
|
||||||
|
Loading…
Reference in New Issue
Block a user