This is an archive of the discontinued LLVM Phabricator instance.

[SVE] Lower vector CTLZ, CTPOP and CTTZ operations.
ClosedPublic

Authored by paulwalker-arm on Dec 20 2020, 5:08 PM.

Details

Summary

CTLZ and CTPOP are lowered to CLZ and CNT instructions respectively.

CTTZ is not a native SVE operation but is instead lowered to:

CTTZ(V) => CTLZ(BITREVERSE(V))

In the case of fixed-length support using SVE we also lower CTTZ
operating on NEON sized vectors because of its reliance on
BITREVERSE which is also lowered to SVE intructions at these lengths.

Depends on D93606

Diff Detail

Event Timeline

paulwalker-arm created this revision.Dec 20 2020, 5:08 PM
paulwalker-arm requested review of this revision.Dec 20 2020, 5:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 20 2020, 5:08 PM

Fixed incorrect variable naming within ctlz_v64i8, ctpop_v64i8, cttz_v64i8.

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
227

The NOT patterns could use some tests. Or are they required for this patch and I missed it?

paulwalker-arm added inline comments.Dec 27 2020, 2:17 AM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
227

This patch doesn't really change anything for NOT, which is still relying directly on the SVE intrinsics for isel. However, the operand order used by the SVE unary intrinsics is different to that used for _MERGE_PASSTHRU nodes:

SVE unary intrinsic = OP <PASSTHRU> <PG> <OPERAND>
Unary_MERGE_PATHRU = OP <PG> <OPERAND> <PATHTHRU>

The above PatFrags is just shuffling the intrinsic operands so that sve_int_un_pred_arit_1 can take a single "op" parameter and have a single set of patterns. The existing tests within sve-intrinsics-logical.ll should ensure that I've not broken isel for the affected intrinsics cls, cnot and not.

I didn't realise this operand shuffling was possibly so I've likely added unnecessary int_op and ir_op parameters to some of the classes under past patches.

This revision is now accepted and ready to land.Jan 4 2021, 7:57 AM
This revision was landed with ongoing or failed builds.Jan 5 2021, 2:57 AM
This revision was automatically updated to reflect the committed changes.