[PATCH] D103755: [DAG] Fold neg(bvsplat(neg(x)) -> bvsplat(x)

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 8 02:22:56 PDT 2021


dmgreen added a comment.

In D103755#2800920 <https://reviews.llvm.org/D103755#2800920>, @RKSimon wrote:

> Funnily enough I was wondering about this pattern the other day as a followup to D98778 <https://reviews.llvm.org/D98778>...
>
> Should we always be folding unaryop(splat(x)) -> splat(unaryop(x)) if the unaryop is legal/custom on the scalar type? And then maybe extend that to binop(splat(x),splat(y)) -> splat(binop(x,y)) as well?

Maybe. Not sure. I always find it difficult to see when optimizations like that would be universally beneficial over a wide range of very different architectures, considering how different they can be. I can see that it would make this more general, but it seems easy to think of cases where it would make things worse.

For this case I think it would need to work with the truncated type, not the scalar element type. For a v8i16 the scalar element type would not be legal under AArch64. If it was using the element type it would only handle half of the tests changed here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103755/new/

https://reviews.llvm.org/D103755



More information about the llvm-commits mailing list