[PATCH] D47986: [CostModel] Treat Identity shuffle masks as zero cost

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 11 11:29:58 PDT 2018


spatel added a comment.

In https://reviews.llvm.org/D47986#1128586, @RKSimon wrote:

> In https://reviews.llvm.org/D47986#1128533, @spatel wrote:
>
> > 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?
>
>
> 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).


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?


Repository:
  rL LLVM

https://reviews.llvm.org/D47986





More information about the llvm-commits mailing list