diff options
author | Fangrui Song <maskray@google.com> | 2019-03-03 14:50:01 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-03-03 14:50:01 +0000 |
commit | 5fa53d159374d4f43e62cfd496488fe544ddaeb5 (patch) | |
tree | 2942579b8a644ade3525a58e403ebc96dcbeaea0 /llvm/lib/Analysis | |
parent | e48be5d698a2a9c23d843812f748cd4921ac7489 (diff) | |
download | bcm5719-llvm-5fa53d159374d4f43e62cfd496488fe544ddaeb5.tar.gz bcm5719-llvm-5fa53d159374d4f43e62cfd496488fe544ddaeb5.zip |
[DemandedBits] Remove some redundancy in the work list
InputIsKnownDead check is shared by all operands. Compute it once.
For non-integer instructions, use Visited.insert(I).second to replace a
find() and an insert().
llvm-svn: 355290
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/DemandedBits.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/DemandedBits.cpp b/llvm/lib/Analysis/DemandedBits.cpp index 48412d204dc..01b8ff10d35 100644 --- a/llvm/lib/Analysis/DemandedBits.cpp +++ b/llvm/lib/Analysis/DemandedBits.cpp @@ -339,6 +339,8 @@ void DemandedBits::performAnalysis() { Type *T = J->getType(); if (T->isIntOrIntVectorTy()) AliveBits[J] = APInt::getAllOnesValue(T->getScalarSizeInBits()); + else + Visited.insert(J); Worklist.insert(J); } } @@ -354,16 +356,18 @@ void DemandedBits::performAnalysis() { LLVM_DEBUG(dbgs() << "DemandedBits: Visiting: " << *UserI); APInt AOut; + bool InputIsKnownDead = false; if (UserI->getType()->isIntOrIntVectorTy()) { AOut = AliveBits[UserI]; LLVM_DEBUG(dbgs() << " Alive Out: 0x" << Twine::utohexstr(AOut.getLimitedValue())); + + // If all bits of the output are dead, then all bits of the input + // are also dead. + InputIsKnownDead = !AOut && !isAlwaysLive(UserI); } LLVM_DEBUG(dbgs() << "\n"); - if (!UserI->getType()->isIntOrIntVectorTy()) - Visited.insert(UserI); - KnownBits Known, Known2; bool KnownBitsComputed = false; // Compute the set of alive bits for each operand. These are anded into the @@ -380,10 +384,7 @@ void DemandedBits::performAnalysis() { if (T->isIntOrIntVectorTy()) { unsigned BitWidth = T->getScalarSizeInBits(); APInt AB = APInt::getAllOnesValue(BitWidth); - if (UserI->getType()->isIntOrIntVectorTy() && !AOut && - !isAlwaysLive(UserI)) { - // If all bits of the output are dead, then all bits of the input - // are also dead. + if (InputIsKnownDead) { AB = APInt(BitWidth, 0); } else { // Bits of each operand that are used to compute alive bits of the @@ -408,7 +409,7 @@ void DemandedBits::performAnalysis() { Worklist.insert(I); } } - } else if (I && !Visited.count(I)) { + } else if (I && Visited.insert(I).second) { Worklist.insert(I); } } |