This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE2] Add the SVE2.1 integer quadword reduction instructions
ClosedPublic

Authored by david-arm on Nov 4 2022, 5:05 AM.

Details

Summary

This patch adds the assembly/disassembly for the following instructions:

addqv : Unsigned add reduction of quadword vector segments
andqv : Bitwise AND reduction of quadword vector segments
eorqv : Bitwise exclusive OR reduction of quadword vector segments
orqv : Bitwise inclusive OR reduction of quadword vector segments
smaxqv : Signed maximum reduction of quadword vector segments
sminqv : Signed minimum reduction of quadword vector segments
umaxqv : Unsigned maximum reduction of quadword vector segments
uminqv : Unsigned minimum reduction of quadword vector segments

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

Diff Detail

Event Timeline

david-arm created this revision.Nov 4 2022, 5:05 AM
Herald added a project: Restricted Project. · View Herald Transcript
david-arm requested review of this revision.Nov 4 2022, 5:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 5:05 AM
paulwalker-arm added inline comments.Nov 4 2022, 7:28 AM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
3744

Please add the usual register suffixes, so _VPZ in this case?

llvm/lib/Target/AArch64/SVEInstrFormats.td
9289

Not your fault but this is a shame because otherwise we could just extend sve_int_reduce.

With that said, are you able to follow the same idiom as sve_int_reduce for the QV reductions because your current direction will mean a separate instruction class per type of reduction and I cannot immediately see a need for that.

Matt added a subscriber: Matt.Nov 5 2022, 8:34 PM
david-arm added inline comments.Nov 7 2022, 1:48 AM
llvm/lib/Target/AArch64/SVEInstrFormats.td
9289

Given they are quite different encodings does this really make sense?

These three encoding groups all differ by 3 bits on top of the opc
SVE bitwise logical reduction (quadwords): bits 21-19: 011
SVE integer add reduction (quadwords): bits 21-19: 000
SVE integer min/max reduction (quadwords): bits 21-19: 001

To be honest I'm quite confused by how the existing sve_int_reduce hierarchy is written. For example, what does the _1 in sve_int_reduce_1 mean and how does that relate to the instructions? Is it just a random suffix? Personally, if we have to go down this route I'd prefer something more meaningful than just copying how we've done this before. Would this be ok?

defm EORQV_VPZ : sve2p1_log_int_reduce_q<...>;
...
defm ADDQV_VPZ : sve2p1_arith_int_reduce_q<...>;
...
defm SMAXQV_VPZ : sve2p1_minmax_int_reduce_q<...>;

where the multiclasses look like

multiclass sve2p1_log_int_reduce_q<bits<2> opc, string mnemonic> {

def _B : sve2p1_int_reduction_q<0b00, opc, 0b011, mnemonic, ZPR8,  "16b">;
def _H : sve2p1_int_reduction_q<0b01, opc, 0b011, mnemonic, ZPR16, "8h">;
def _S : sve2p1_int_reduction_q<0b10, opc, 0b011, mnemonic, ZPR32, "4s">;
def _D : sve2p1_int_reduction_q<0b11, opc, 0b011, mnemonic, ZPR64, "2d">;

}

where 0b011 refers to bits 21-19 of the encoding group.

paulwalker-arm added inline comments.Nov 7 2022, 3:01 AM
llvm/lib/Target/AArch64/SVEInstrFormats.td
9289

From what I can see all the quadword reductions (e.g. SMAXQV) differ by a single bit (18) when compared to their equivalent predicated reductions (e.g. SMAXV). Given this I don't see any reason why you should not use the same structure.

In this instance I'm not asking you to reuse any existing classes (that would be amazing but the current parsing of NEON registers precludes it) so I guess I'm just saying you can copy sve_int_reduce as sve_int_reduce_quadwards and then create the three multiclasses as you've described above.

Please go with whatever names you think best. The use of numerical suffixes were an attempt to maintain alignment within AArch64SVEInstrInfo, but there's no requirement for that. I will say the names are somewhat irrelevant though, it's the instruction names that people will be searching for.

david-arm updated this revision to Diff 474227.Nov 9 2022, 4:55 AM
david-arm retitled this revision from [AArch64][SVE2] Add the SVE2.1 logical quadword reduction instructions to [AArch64][SVE2] Add the SVE2.1 integer quadword reduction instructions.
david-arm edited the summary of this revision. (Show Details)
  • Rewrite as a single class to cover all the logical/add/min/max reductions from this patch and D137412, D137420.
david-arm marked 2 inline comments as done.Nov 9 2022, 4:56 AM
david-arm added inline comments.
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
3744

I just realised I forgot to add the suffixes. I can do that in a follow-up.

paulwalker-arm accepted this revision.Nov 9 2022, 5:48 AM
This revision is now accepted and ready to land.Nov 9 2022, 5:48 AM
paulwalker-arm added inline comments.Nov 9 2022, 5:50 AM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
3744

Thanks @david-arm, please remember to do this before landing the patch.

This revision was landed with ongoing or failed builds.Nov 9 2022, 6:26 AM
This revision was automatically updated to reflect the committed changes.