[PATCH] D89956: [AArch64] Redundant masks in downcast long multiply
Nicholas Guy via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 22 06:25:49 PDT 2020
NickGuy created this revision.
NickGuy added reviewers: SjoerdMeijer, dmgreen, t.p.northover, efriedma.
NickGuy added a project: LLVM.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
NickGuy requested review of this revision.
Adds patterns to catch masks preceeding a long multiply,
and generating a single umull/smull instruction instead.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89956
Files:
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/test/CodeGen/AArch64/aarch64-mull-masks.ll
Index: llvm/test/CodeGen/AArch64/aarch64-mull-masks.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/aarch64-mull-masks.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64-none-linux-gnu < %s -o -| FileCheck %s
+
+define i64 @umull(i64 %x0, i64 %x1) {
+; CHECK-LABEL: umull:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: umull x0, w1, w0
+; CHECK-NEXT: ret
+entry:
+ %and = and i64 %x0, 4294967295
+ %and1 = and i64 %x1, 4294967295
+ %mul = mul nuw i64 %and1, %and
+ ret i64 %mul
+}
+
+define i64 @smull(i64 %x0, i64 %x1) {
+; CHECK-LABEL: smull:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: smull x0, w1, w0
+; CHECK-NEXT: ret
+entry:
+ %sext = shl i64 %x0, 32
+ %conv1 = ashr exact i64 %sext, 32
+ %sext4 = shl i64 %x1, 32
+ %conv3 = ashr exact i64 %sext4, 32
+ %mul = mul nsw i64 %conv3, %conv1
+ ret i64 %mul
+}
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===================================================================
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -1473,6 +1473,11 @@
def UMADDLrrr : WideMulAccum<0, 0b101, "umaddl", add, zext>;
def UMSUBLrrr : WideMulAccum<1, 0b101, "umsubl", sub, zext>;
+def : Pat<(mul (sext_inreg GPR64:$Rn, i32), (sext_inreg GPR64:$Rm, i32)),
+ (SMADDLrrr (EXTRACT_SUBREG $Rn, sub_32), (EXTRACT_SUBREG $Rm, sub_32), XZR)>;
+def : Pat<(mul (and GPR64:$Rn, 0xFFFFFFFF), (and GPR64:$Rm, 0xFFFFFFFF)),
+ (UMADDLrrr (EXTRACT_SUBREG $Rn, sub_32), (EXTRACT_SUBREG $Rm, sub_32), XZR)>;
+
def : Pat<(i64 (mul (sext GPR32:$Rn), (sext GPR32:$Rm))),
(SMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
def : Pat<(i64 (mul (zext GPR32:$Rn), (zext GPR32:$Rm))),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89956.299943.patch
Type: text/x-patch
Size: 1852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201022/46cfcf1a/attachment.bin>
More information about the llvm-commits
mailing list