[PATCH] D87378: [SVE] Fix InstCombinerImpl::PromoteCastOfAllocation for scalable vectors

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 06:51:36 PDT 2020


david-arm created this revision.
david-arm added reviewers: sdesmalen, ctetreau, c-rhodes.
Herald added subscribers: llvm-commits, psnobl, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.
david-arm requested review of this revision.

In this patch I've fixed some warnings that arose from the implicit
cast of TypeSize -> uint64_t. I tried writing a variety of different
cases to show how this optimisation might work for scalable vectors
and found:

1. The optimisation does not work for cases where the casted type

is scalable and the allocated type is not. This because we need to
know how many times the casted type fits into the allocated type.

2. If we pass all the various checks for the case when the allocated

type is scalable and the casted type is not, then when creating the
new alloca we have to take vscale into account. This leads to
sub-optimal IR that is worse than the original IR.

3. For the remaining case when both the alloca and cast types are

scalable it is hard to find examples where the optimisation would
kick in because we typically fail the ABI alignment checks.

For now it seems better to simply bail out of this optimisation
until we're presented with a case where it's worthwhile.

I've added tests that show we don't attempt to promote the alloca:

  Transforms/InstCombine/AArch64/sve-cast-of-alloc.ll


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87378

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/test/Transforms/InstCombine/AArch64/sve-cast-of-alloc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87378.290730.patch
Type: text/x-patch
Size: 7510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200909/96dcb38e/attachment.bin>


More information about the llvm-commits mailing list