[unroll] Directly query for dead instructions.

In the unroll analyzer, it is checking each user to see if that user
will become dead. However, it first checked if that user was missing
from the simplified values map, and then if was also missing from the
dead instructions set. We add everything from the simplified values map
to the dead instructions set, so the first step is completely subsumed
by the second. Moreover, the first step requires *inserting* something
into the simplified value map which isn't what we want at all.

This also replaces a dyn_cast with a cast as an instruction cannot be
used by a non-instruction.

llvm-svn: 229057
This commit is contained in:
Chandler Carruth 2015-02-13 04:14:05 +00:00
parent 82cb30f10c
commit 06d537cdd6
1 changed files with 3 additions and 4 deletions

View File

@ -543,13 +543,12 @@ public:
if (DeadInstructions.count(I))
continue;
bool AllUsersFolded = true;
for (User *U : I->users()) {
Instruction *UI = dyn_cast<Instruction>(U);
if (!SimplifiedValues[UI] && !DeadInstructions.count(UI)) {
for (User *U : I->users())
if (!DeadInstructions.count(cast<Instruction>(U))) {
AllUsersFolded = false;
break;
}
}
if (AllUsersFolded) {
NumberOfOptimizedInstructions += TTI.getUserCost(I);
DeadInstructions.insert(I);