[PATCH] D120129: [NVPTX] Enhance vectorization of ld.param & st.param

Daniil Kovalev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 18 06:29:36 PST 2022


kovdan01 created this revision.
kovdan01 added reviewers: tra, jholewinski, jlebar.
Herald added subscribers: asavonic, hiraditya.
kovdan01 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Since function parameters and return values are passed via param space, we
can force special alignment for values hold in it which will add vectorization
options. This change may be done if the function has private or internal
linkage. Special alignment is forced during 2 phases.

1. Instruction selection lowering. Here we use special alignment for function prototypes (changing both own return value and parameters alignment), call lowering (changing both callee's return value and parameters alignment).

2. IR pass nvptx-lower-args. Here we change alignment of byval parameters that belong to param space (or are casted to it). We only handle cases when all uses of such parameters are loads from it. For such loads, we can change the alignment according to special type alignment and the load offset. Then, load-store-vectorizer IR pass will perform vectorization where alignment allows it.

Special alignment is calculated as follows. Let A is the default ABI alignment
of a type, S - the size of the type. Given that:

- If S is a multiple of 4 * A, let special alignment be 4 * A.
- Else, if S is a multiple of 2 * A, let special alignment be 2 * A.
- Else, let special alignment be A.

Before specifying such special alignment, we should check if it is a multiple
of the alignment that the type already has. For example, if a type has an
enforced alignment of 64, default ABI alignment of 4 and special alignment
of 16, we should preserve 64.

This patch will be followed by a refactoring patch that removes duplicating
code in handling byval and non-byval arguments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120129

Files:
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.h
  llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
  llvm/test/CodeGen/NVPTX/param-vectorize.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120129.409917.patch
Type: text/x-patch
Size: 57508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220218/94b7fbbe/attachment-0001.bin>


More information about the llvm-commits mailing list