This is an archive of the discontinued LLVM Phabricator instance.

[SLP] Ignore unreachable blocks
ClosedPublic

Authored by hvdijk on Jun 1 2021, 11:48 AM.

Details

Summary

As the existing test unreachable.ll shows, we should be doing more
work to avoid entering unreachable blocks: we should not stop
vectorization just because a PHI incoming value from an unreachable
block cannot be vectorized. We know that particular value will never
be used so we can just replace it with poison.

Diff Detail

Event Timeline

hvdijk created this revision.Jun 1 2021, 11:48 AM
hvdijk requested review of this revision.Jun 1 2021, 11:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2021, 11:48 AM
ABataev added inline comments.Jun 1 2021, 11:57 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2833–2834

Better to do something like this:

if (!DT->isReachableFromEntry(PH->getIncomingBlock(I))) {
  ValueList Operands(VL.size(), PoisonValue::get(PH->getType()));
  TE->setOperand(I, Operands);
  OperandsVec.push_back(Operands);
  continue;
}

and remove the change in BoUpSLP::vectorizeTree

hvdijk updated this revision to Diff 349053.Jun 1 2021, 12:15 PM
hvdijk marked an inline comment as done.
hvdijk added inline comments.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2833–2834

Good idea, re-ran tests with exactly what you put here, that works.

hvdijk marked an inline comment as done.Jun 1 2021, 12:17 PM
This revision is now accepted and ready to land.Jun 1 2021, 12:20 PM
hvdijk closed this revision.Jun 1 2021, 12:22 PM

Thanks. Accidentally pushed without updating the commit message, linking and closing manually.