[PATCH] D67109: [ARM] Add patterns for CTLZ on MVE
oliver cruickshank via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 09:51:52 PDT 2019
oliverlars created this revision.
oliverlars added reviewers: dmgreen, SjoerdMeijer, samparker, simon_tatham, t.p.northover.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls, javed.absar.
Herald added a project: LLVM.
CTLZ intrinsic can use the VCLS instruction on MVE, which produces better results than expanding.
Repository:
rL LLVM
https://reviews.llvm.org/D67109
Files:
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMInstrMVE.td
llvm/test/CodeGen/Thumb2/mve-ctlz.ll
Index: llvm/test/CodeGen/Thumb2/mve-ctlz.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-ctlz.ll
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main-arm-none-eabi -mattr=+mve %s -o - | FileCheck %s
+
+define arm_aapcs_vfpcc <4 x i32> @ctlz_4i32_t(<4 x i32> %src){
+; CHECK-LABEL: ctlz_4i32_t:
+; CHECK: @ %bb.0: @ %entry
+; CHECK-NEXT: vclz.i32 q0, q0
+; CHECK-NEXT: bx lr
+entry:
+ %0 = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %src)
+ ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @ctlz_8i16_t(<8 x i16> %src){
+; CHECK-LABEL: ctlz_8i16_t:
+; CHECK: @ %bb.0: @ %entry
+; CHECK-NEXT: vclz.i16 q0, q0
+; CHECK-NEXT: bx lr
+entry:
+ %0 = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> %src)
+ ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @ctlz_16i8_t(<16 x i8> %src){
+; CHECK-LABEL: ctlz_16i8_t:
+; CHECK: @ %bb.0: @ %entry
+; CHECK-NEXT: vclz.i8 q0, q0
+; CHECK-NEXT: bx lr
+entry:
+ %0 = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %src)
+ ret <16 x i8> %0
+}
+
+declare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>)
+declare <8 x i16> @llvm.ctlz.v8i16(<8 x i16>)
+declare <16 x i8> @llvm.ctlz.v16i8(<16 x i8>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===================================================================
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -1724,6 +1724,16 @@
def MVE_VCLZs16 : MVE_VCLSCLZ<"vclz", "i16", 0b01, 0b1>;
def MVE_VCLZs32 : MVE_VCLSCLZ<"vclz", "i32", 0b10, 0b1>;
+let Predicates = [HasMVEInt] in {
+ def : Pat<(v16i8 ( ctlz (v16i8 MQPR:$val1))),
+ (v16i8 ( MVE_VCLZs8 (v16i8 MQPR:$val1)))>;
+ def : Pat<(v4i32 ( ctlz (v4i32 MQPR:$val1))),
+ (v4i32 ( MVE_VCLZs32 (v4i32 MQPR:$val1)))>;
+ def : Pat<(v8i16 ( ctlz (v8i16 MQPR:$val1))),
+ (v8i16 ( MVE_VCLZs16 (v8i16 MQPR:$val1)))>;
+
+}
+
class MVE_VABSNEG_int<string iname, string suffix, bits<2> size, bit negate,
list<dag> pattern=[]>
: MVEIntSingleSrc<iname, suffix, size, pattern> {
Index: llvm/lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -259,6 +259,7 @@
setOperationAction(ISD::UMAX, VT, Legal);
setOperationAction(ISD::ABS, VT, Legal);
setOperationAction(ISD::SETCC, VT, Custom);
+ setOperationAction(ISD::CTLZ, VT, Legal);
// No native support for these.
setOperationAction(ISD::UDIV, VT, Expand);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67109.218473.patch
Type: text/x-patch
Size: 2676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190903/55458170/attachment.bin>
More information about the llvm-commits
mailing list