This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] try to reduce shuffle with bitcasted operand
ClosedPublic

Authored by spatel on Mar 26 2020, 6:37 AM.

Details

Summary

shuf (bitcast X), undef, Mask --> bitcast X'

The 'inverse shuffles' test (shuf_bitcast_operand) is a pattern that would emerge in the motivating examples from PR35454:
https://bugs.llvm.org/show_bug.cgi?id=35454
(if we proceed with D76727)

We can deal with this class of patterns in generic instcombine because we are not creating any new shuffles, just a bitcast.

This provides an opportunity to exercise Alive2's vector support:
http://volta.cs.utah.edu:8080/z/mwDUZf

Diff Detail

Event Timeline

spatel created this revision.Mar 26 2020, 6:37 AM
RKSimon added inline comments.Mar 26 2020, 7:33 AM
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
1927

Its seems a pity to create a speculative ConstantVector like this - can we easily refactor SimplifyShuffleVectorInst to take ArrayRef<int> ?

liuz added a subscriber: liuz.Mar 26 2020, 7:37 AM
spatel marked an inline comment as done.Mar 26 2020, 9:19 AM
spatel added a subscriber: efriedma.
spatel added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
1927

The diffs we want are part of D72467.
@efriedma - is that patch held up on anything? We may not have settled on the scalable vector future, but changing the fixed vector implementation would make things easier for existing code today.

efriedma added inline comments.Mar 26 2020, 9:57 AM
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
1927

I'll go over it one more time, but I don't think it's held up on anything in particular. We didn't completely reach consensus on scalable vector shuffles, but the result is almost certainly compatible with that patch. I'll try to land it today.

lebedev.ri accepted this revision.Mar 26 2020, 12:16 PM

This seems reasonable to me, unless @RKSimon has concerns.

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
1920–1922

Same comment about reserve+range-based-for, although i hope that will get obsoleted by D72467?

This revision is now accepted and ready to land.Mar 26 2020, 12:16 PM
spatel marked an inline comment as done.Mar 26 2020, 1:00 PM
spatel added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
1920–1922

Yes, if we convert the mask from a constant operand to a special constant, then this and other code gets simplified away.

D72467 is not actually a parent, but adding that here because this would conflict (force another rebase of that patch).

spatel updated this revision to Diff 254563.Apr 2 2020, 10:43 AM
spatel marked 3 inline comments as done.

Patch updated - no logic changes, but rebased/reduced with new shuffle instruction.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 2 2020, 10:51 AM