This is an archive of the discontinued LLVM Phabricator instance.

[x86] Teach the target-specific combining how to aggressively fold half-shuffles, even looking through intervening instructions in a chain.
ClosedPublic

Authored by chandlerc on Jun 25 2014, 6:51 AM.

Details

Summary

This doesn't happen to show up with any test cases I've found for the current
shuffle lowering, but previous attempts would benefit from this and it seems
generally useful. I've tested it directly using intrinsics, which also shows
that it will work with hand vectorized code as well.

Note that even though pshufd isn't directly used in these tests, it gets
exercised because we combine some of the half shuffles into a pshufd
first, and then merge them.

Diff Detail

Repository
rL LLVM

Event Timeline

chandlerc updated this revision to Diff 10834.Jun 25 2014, 6:51 AM
chandlerc retitled this revision from to [x86] Teach the target-specific combining how to aggressively fold half-shuffles, even looking through intervening instructions in a chain..
chandlerc updated this object.
chandlerc edited the test plan for this revision. (Show Details)
chandlerc added reviewers: grosbach, filcab.
chandlerc added a subscriber: Unknown Object (MLST).
grosbach accepted this revision.Jun 25 2014, 10:08 AM
grosbach edited edge metadata.

Nitty comments inline. Code looks great.

lib/Target/X86/X86ISelLowering.cpp
19002 ↗(On Diff #10834)

grammar. "if the halves" maybe what you meant?

19006 ↗(On Diff #10834)

"of it's input" sounds odd, but I'm not sure it's wrong. Can you rephrase?

19032 ↗(On Diff #10834)

s/nodes/node's/

test/CodeGen/X86/vector-shuffle-combining.ll
11 ↗(On Diff #10834)

I prefer not to look for these sorts of comments in test lines if at all possible and to just run llc with -asm-verbose=false. That enables explicit CHECK-NEXT for instructions right after the function label to make sure there's not extraneous stuff showing up, which looks like what you're trying to do here.

This revision is now accepted and ready to land.Jun 25 2014, 10:08 AM
filcab accepted this revision.Jun 25 2014, 3:30 PM
filcab edited edge metadata.

LGTM

Generally, will apply fixes before submitting. One note though.

test/CodeGen/X86/vector-shuffle-combining.ll
11 ↗(On Diff #10834)

I understand your hesitance, but with shuffles, I think we have to use comment-based checking. It is essential to write the shuffle instruction check lines using the comments that decode the operands rather than having opaque "$-27" and company in check lines.

Applying with suggested fixes generally. Thanks!

lib/Target/X86/X86ISelLowering.cpp
19002 ↗(On Diff #10834)

No, its the rest of the sentence that had the wrong grammar. =]

19006 ↗(On Diff #10834)

Old comment, the one above i think is closer despite the grammar fail. Nuked this one.

chandlerc closed this revision.Jun 27 2014, 4:42 AM
chandlerc updated this revision to Diff 10924.

Closed by commit rL211890 (authored by @chandlerc).