[PATCH] D141240: [SVE][Builtins] Add metadata to intrinsic calls for builtins that don't define the result of inactive lanes.

Paul Walker via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 8 16:39:45 PST 2023


paulwalker-arm created this revision.
Herald added subscribers: ctetreau, psnobl, hiraditya, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: All.
paulwalker-arm requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

The ACLE for SVE define a repeating set of builtins that allow the
result of inactive lanes to be zeroed (Z), copied from an input
operand (M) or have an undefined value (X).  When lowering these
builtins we lose the semantics of the undefined variants because to
keep the intrinsic count down we chose to treat them as M forms.

This largely makes sense because in the majority of instances only
the M form is backed by a real instruction.  This does mean we miss
out on some optimisation opportunities and so this patch introduces
metadata to the intrinsic calls that allow us to represent the cases
where an M form can be considered to be an X form.  This metadata is
freely ignorable because copying the inactive lanes from an input
operand is a valid option to represent an undefined value, and
matches the behaviour before this patch.

To demonstrate the metadata's usage this patch includes a trivial
optimisation so that svadd_x emits the unpredicated variant of ADD
as expected.

NOTE: I did investigate representing the undefined lanes using a
select on the governing predicate but this proved a poor design
because optimisations became order sensitive, the extra IR made use
count protection harder to handle and the select instruction itself
has strict rules relating to poison that hampered the intent of this
change.



NOTE: All the existing tests pass without regeneration and so to
keep the reviewed patch small I only regenerated one of the tests
to show the affect.  If agreeable I'll regenerate all the other
tests just before landing the patch.

Depends on D141056 <https://reviews.llvm.org/D141056>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141240

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_add.c
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-unpredicate.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141240.487245.patch
Type: text/x-patch
Size: 40072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230109/e63f55ce/attachment-0001.bin>


More information about the cfe-commits mailing list