This is an archive of the discontinued LLVM Phabricator instance.

[SLP][NFC] Assert that tree entry operands completed when scheduler looks for dependencies.
ClosedPublic

Authored by vdmitrie on Feb 27 2020, 1:01 PM.

Details

Summary

This change adds an assertion to prevent tricky bug related to recursive
approach of building vectorization tree. For loop below takes number of
operands directly from tree entry rather than from scalars.
If the entry at this moment turns out incomplete (i.e. not all operands set)
then not all the dependencies will be seen by the scheduler.
This situation can lead to failed scheduling (and thus failed vectorization).
Here is code example originating it:

for (i : VL0->getNumOperands()) {
  ...
  TE->setOperand(i, Operands);
  buildTree_rec(Operands, Depth + 1,...);
}

Correct way is two steps process: first set all operand to the tree entry and
then recursively process each operand.

Diff Detail

Event Timeline

vdmitrie created this revision.Feb 27 2020, 1:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2020, 1:01 PM

Maybe it is better to implement the two-steps approach? If it may lead to a crash, it will definitely cause a crash somewhere

Maybe it is better to implement the two-steps approach? If it may lead to a crash, it will definitely cause a crash somewhere

I'm not sure I got your question. The two steps approach is what is implemented and used at the moment. Example in the summary shows situation leading to firing the assertion.

Maybe it is better to implement the two-steps approach? If it may lead to a crash, it will definitely cause a crash somewhere

I'm not sure I got your question. The two steps approach is what is implemented and used at the moment. Example in the summary shows situation leading to firing the assertion.

SO, we have correct implementation and this is just a check to prevent possible bugs in the future?

SO, we have correct implementation and this is just a check to prevent possible bugs in the future?

Right.

ABataev accepted this revision.Feb 27 2020, 2:03 PM

LGTM

This revision is now accepted and ready to land.Feb 27 2020, 2:03 PM
This revision was automatically updated to reflect the committed changes.