[AArch64][SVE] Add a pass for SVE intrinsic optimisations
authorKerry McLaughlin <kerry.mclaughlin@arm.com>
Tue, 14 Apr 2020 08:52:04 +0000 (09:52 +0100)
committerKerry McLaughlin <kerry.mclaughlin@arm.com>
Tue, 14 Apr 2020 09:41:49 +0000 (10:41 +0100)
commit36c76de6789c2503e800ec37243aa13698c59928
treec6787370c240b074abcb4ecf9c212567906a5be2
parent31c8e118961913341e4f5c066bbdcf9b3d2109c7
[AArch64][SVE] Add a pass for SVE intrinsic optimisations

Summary:
Creates the SVEIntrinsicOpts pass. In this patch, the pass tries
to remove unnecessary reinterpret intrinsics which convert to
and from svbool_t (llvm.aarch64.sve.convert.[to|from].svbool)

For example, the reinterprets below are redundant:

  %1 = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> %a)
  %2 = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %1)

The pass also looks for ptest intrinsics and phi instructions where
the operands are being needlessly converted to and from svbool_t.

Reviewers: sdesmalen, andwar, efriedma, cameron.mcinally, c-rhodes, rengolin

Reviewed By: efriedma

Subscribers: mgorny, tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, danielkiss, cfe-commits, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76078
llvm/lib/Target/AArch64/AArch64.h
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/AArch64/CMakeLists.txt
llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp [new file with mode: 0644]
llvm/test/CodeGen/AArch64/O3-pipeline.ll
llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll [new file with mode: 0644]
llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll [new file with mode: 0644]