This is an archive of the discontinued LLVM Phabricator instance.

[SLP]Fix PR57447: Assertion `!getTreeEntry(V) && "Scalar already in tree!"' failed.
ClosedPublic

Authored by ABataev on Aug 30 2022, 8:35 AM.

Details

Summary

The pointer operands for the ScatterVectorize node may contain
non-instruction values and they are not checked for "already being
vectorized". Need to check that such pointers are already vectorized and
gather them instead of trying to build vectorize node to avoid compiler
crash.

Diff Detail

Event Timeline

ABataev created this revision.Aug 30 2022, 8:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2022, 8:35 AM
ABataev requested review of this revision.Aug 30 2022, 8:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2022, 8:35 AM
vdmitrie added inline comments.Aug 30 2022, 11:04 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
4769

"!I" can be replaced with "!isa<Instruction>(V)"
We already have few places of the same pattern addressing specifically the operand of a ScatterVectorize node: " UserTreeIdx.UserTE && UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize".
We also define isScatterUser variable at line 5221 with the same value.
I'd suggest to pull the variable definition up and use it instead of the repeating pattern.
The comment before the loop is probably worth updating too.

vdmitrie added inline comments.Aug 30 2022, 11:19 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
4769

A side note. IMO terminology used here in SLP vectorizer wrt vectorizing non-unit stride loads is really confusing as word "scatter" is typically associated with stores. But I'm not about changing the naming in context of this PR. What I wanted to highlight is that IsScatterUser is also not the best choice for the variable name. It is even more confusing because it sounds like "this VL is a user of ScatterVectorizer node" (which by the way may not have users as loads are terminators) rather than "user of this VL is ScatterVectorize node". It would be nice if you come up with better name for the variable (preferably not having "scatter" in its name).

vdmitrie added inline comments.Aug 30 2022, 11:26 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
4769

(which by the way may not have users

ignore this part:) My brain again thinking of "stores" when I see "scatter" ))

ABataev updated this revision to Diff 456741.Aug 30 2022, 11:49 AM

Address comment

vdmitrie accepted this revision.Aug 30 2022, 12:03 PM

LG. Thanks!

This revision is now accepted and ready to land.Aug 30 2022, 12:03 PM
This revision was landed with ongoing or failed builds.Aug 30 2022, 12:31 PM
This revision was automatically updated to reflect the committed changes.