Page MenuHomePhabricator

[SLP]Improve splat detection.
ClosedPublic

Authored by ABataev on Fri, Nov 12, 7:14 AM.

Details

Summary

A bunch of scalars can be treated as a splat not only if all elements
are the same but also if some of them are undefvalues.

Diff Detail

Event Timeline

ABataev created this revision.Fri, Nov 12, 7:14 AM
ABataev requested review of this revision.Fri, Nov 12, 7:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Nov 12, 7:14 AM
vporpo added a subscriber: vporpo.Fri, Nov 12, 12:15 PM
vporpo added inline comments.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
257–258

Please update the comment to mention that this also accepts undefs.

260–268

NIT: Perhaps renaming V to something like FirstNonUndef would make this more readable.

ABataev updated this revision to Diff 386922.Fri, Nov 12, 12:28 PM

Address comments

RKSimon added inline comments.Sat, Nov 13, 3:17 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
261

for-range loop?

270–271

Should we accept all undef cases? The comment says 'some'.

return FirstNonUndef != nullptr;
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

Change it or just remove?

ABataev added inline comments.Mon, Nov 15, 6:38 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

Why?

ABataev updated this revision to Diff 387241.Mon, Nov 15, 6:47 AM

Rebase + address comments.

RKSimon accepted this revision.Mon, Nov 15, 7:33 AM

LGTM - cheers

This revision is now accepted and ready to land.Mon, Nov 15, 7:33 AM
This revision was landed with ongoing or failed builds.Mon, Nov 15, 7:51 AM
This revision was automatically updated to reflect the committed changes.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

Entry->Scalars[0] can be undef with this patch, for this case the output is uninformative.

ABataev added inline comments.Mon, Nov 15, 9:17 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

Hard to tell, this is still the very first element of the entry.

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

Hmm, but why do we output the very first element specially? If Scalars = { undef, add .., add .., add .. }, we label this as <splat> undef. I would just remove this block at all, since "splat" now doesn't mean what it meant before.

ABataev added inline comments.Mon, Nov 15, 9:51 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

Better to output all the scalars here, I think

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

That's exactly what I mean by removing this if-block which early returns otherwise.

ABataev added inline comments.Mon, Nov 15, 10:02 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

So, you suggest to remove << *Entry->Scalars[0]; and ёкуегкт Str;? We can keep splat` label here.

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

Ok, keep "splat" label, but remove return Str; below.

ABataev added inline comments.Mon, Nov 15, 10:08 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
2596

Ok, will do in a separate patch