This is an archive of the discontinued LLVM Phabricator instance.

[SLP][NFC] Restructure getInsertIndex
ClosedPublic

Authored by skc7 on Nov 7 2022, 9:37 AM.

Details

Summary

Fix getInsertIndex to correctly cast to FixedVectorType.
This is required because insertElement instructions can use scalable vectors aswell.

Diff Detail

Event Timeline

skc7 created this revision.Nov 7 2022, 9:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 7 2022, 9:37 AM
skc7 requested review of this revision.Nov 7 2022, 9:37 AM
ABataev added inline comments.Nov 7 2022, 10:01 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
292–293

Could you simplify it?

const auto *VT = dyn_cast<FixedVectorType>(IE->getType());
if (!VT)
  return None;
        
const auto *CI = dyn_cast<ConstantInt>(IE->getOperand(2));
if (!CI)
  return None;

if (CI->getValue().uge(VT->getNumElements()))
  return None;

Index *= VT->getNumElements();
Index += CI->getZExtValue();
return Index;
skc7 updated this revision to Diff 473857.Nov 7 2022, 7:35 PM

changes as per review suggestion.

This revision is now accepted and ready to land.Nov 8 2022, 4:14 AM
This revision was automatically updated to reflect the committed changes.