This is an archive of the discontinued LLVM Phabricator instance.

[SLPVectorizer] Fix crash in isShuffle with scalable vectors
ClosedPublic

Authored by kmclaughlin on Sep 28 2021, 10:27 AM.

Details

Summary

D104809 changed buildTree_rec to check for extract element instructions
with scalable types. However, if the extract is extended or truncated,
these changes do not apply and we assert later on in isShuffle(), which
attempts to cast the type of the extract to FixedVectorType.

Diff Detail

Event Timeline

kmclaughlin created this revision.Sep 28 2021, 10:27 AM
kmclaughlin requested review of this revision.Sep 28 2021, 10:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2021, 10:27 AM

Hi @ABataev, I've added a fix for this assertion failure in the same place as you suggested on a previous patch, D104809. Since this is quite similar and there would now be two fixes in buildTree_rec for the same issue, I was wondering if you think it's worth revisiting the fix @CarolineConcatto first proposed on that patch? Her first revision added the phiNodeHasScalableOp & basicBlockHasScalableOp functions to avoid vectorizing early if there are any instructions found with scalable types.

Hi @ABataev, I've added a fix for this assertion failure in the same place as you suggested on a previous patch, D104809. Since this is quite similar and there would now be two fixes in buildTree_rec for the same issue, I was wondering if you think it's worth revisiting the fix @CarolineConcatto first proposed on that patch? Her first revision added the phiNodeHasScalableOp & basicBlockHasScalableOp functions to avoid vectorizing early if there are any instructions found with scalable types.

I think the current implementation is still good. Also, isShuffle is called in several places, which one causes the crash?

In D110640#3028021, @ABataev wrote:
I think the current implementation is still good. Also, isShuffle is called in several places, which one causes the crash?

It's the isShuffle call in isFullyVectorizableTinyTree that caused the crash here, which was reached through vectorizeGEPIndices->tryToVectorizeList.

In D110640#3028021, @ABataev wrote:
I think the current implementation is still good. Also, isShuffle is called in several places, which one causes the crash?

It's the isShuffle call in isFullyVectorizableTinyTree that caused the crash here, which was reached through vectorizeGEPIndices->tryToVectorizeList.

Just check for scalable vectors before this isShuffle function call.

Just check for scalable vectors before this isShuffle function call.

Alternatively, do we want to rename isShuffle to isFixedVectorShuffle and return None if the extract-element's vector operand type is scalable?

Just check for scalable vectors before this isShuffle function call.

Alternatively, do we want to rename isShuffle to isFixedVectorShuffle and return None if the extract-element's vector operand type is scalable?

Yep, that's a good option too.

  • Removed changes to buildTree_rec.
  • Renamed isShuffle to isFixedVectorShuffle and changed this to return None if the type of the extract element instruction is scalable.
This revision is now accepted and ready to land.Sep 30 2021, 6:34 AM