aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringBase.cpp
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2022-02-11 18:28:56 +0000
committerDavid Green <david.green@arm.com>2022-02-11 18:28:56 +0000
commit4072e362c0307f736c3d8095a0a136b46730cffe (patch)
tree864a043fe09420b6f7447e2bfec7b7fad01c9bdc /llvm/lib/CodeGen/TargetLoweringBase.cpp
parentd828281e7860b5e812474212bfc49cc57d52dae0 (diff)
downloadllvm-4072e362c0307f736c3d8095a0a136b46730cffe.zip
llvm-4072e362c0307f736c3d8095a0a136b46730cffe.tar.gz
llvm-4072e362c0307f736c3d8095a0a136b46730cffe.tar.bz2
[ISel] Port AArch64 HADD and RHADD to ISel
This ports the aarch64 combines for HADD and RHADD over to DAG combine, so that they can be used in more architectures (notably MVE in a followup patch). They are renamed to AVGFLOOR and AVGCEIL in the process, to avoid confusion with instructions such as X86 hadd. The code was also rewritten slightly to remove the AArch64 idiosyncrasies. The general pattern for a AVGFLOORS is %xe = sext i8 %x to i32 %ye = sext i8 %y to i32 %a = add i32 %xe, %ye %r = lshr i32 %a, 1 %t = trunc i32 %r to i8 An AVGFLOORU is equivalent with zext. Because of the truncate lshr==ashr, as the top bits are not demanded. An AVGCEIL also includes an extra rounding, so includes an extra add of 1. Differential Revision: https://reviews.llvm.org/D106237
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringBase.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index ab57423..3a7e82c 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -817,6 +817,12 @@ void TargetLoweringBase::initActions() {
setOperationAction(ISD::SUBC, VT, Expand);
setOperationAction(ISD::SUBE, VT, Expand);
+ // Halving adds
+ setOperationAction(ISD::AVGFLOORS, VT, Expand);
+ setOperationAction(ISD::AVGFLOORU, VT, Expand);
+ setOperationAction(ISD::AVGCEILS, VT, Expand);
+ setOperationAction(ISD::AVGCEILU, VT, Expand);
+
// Absolute difference
setOperationAction(ISD::ABDS, VT, Expand);
setOperationAction(ISD::ABDU, VT, Expand);