As discussed on D47985, identity shuffle masks should probably be free.
I've limited this to the case where the input and output types all match - but we could probably accept all cases.
Paths
| Differential D47986
[CostModel] Treat Identity shuffle masks as zero cost ClosedPublic Authored by RKSimon on Jun 9 2018, 1:36 PM.
Details Summary As discussed on D47985, identity shuffle masks should probably be free. I've limited this to the case where the input and output types all match - but we could probably accept all cases.
Diff Detail
Event TimelineComment Actions We should fold these in InstSimplify, so assigning a zero cost seems appropriate, but that raises the question: who's creating these? Couldn't they call llvm::SimplifyShuffleVectorInst() and short-circuit the problem? Comment Actions
I believe this is the default expansion of the reduction intrinsics - I suppose specifying undef in the upper lanes is useful to help propagate demanded elts so InstSimplify might prevent further improvements if it prematurely optimizes? I know there are a couple of tests in AMDGPU that was specifying an identity shuffle as one of its costs tests (it expects it to be recognised as a SK_PermuteSingleSrc which is free - so this patch isn't affecting it). Comment Actions
Ah, I forgot about that lack of seeing through undef elts in InstSimplify. So we probably want to handle non-canonical IR in the cost model either way to be safe. Add a test where we're selecting from operand 1 rather than operand 0, so we have some coverage for that case too then? This revision is now accepted and ready to land.Jun 12 2018, 7:28 AM Closed by commit rL334506: [CostModel] Treat Identity shuffle masks as zero cost (authored by RKSimon). · Explain WhyJun 12 2018, 7:51 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 150906 lib/Analysis/TargetTransformInfo.cpp
test/Analysis/CostModel/X86/reduction.ll
test/Analysis/CostModel/X86/shuffle-single-src.ll
|