This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add missing vrnd intrinsics
ClosedPublic

Authored by miyengar on Aug 23 2023, 8:23 AM.

Details

Summary

This patch adds 8 missing intrinsics as specified in the Arm ACLE document section 2.12.1.1 : https://arm-software.github.io/acle/neon_intrinsics/advsimd.html#rounding-3

The intrinsics implemented are:

  • vrnd32z_f64
  • vrnd32zq_f64
  • vrnd64z_f64
  • vrnd64zq_f64
  • vrnd32x_f64
  • vrnd32xq_f64
  • vrnd64x_f64
  • vrnd64xq_f64

Diff Detail

Event Timeline

miyengar created this revision.Aug 23 2023, 8:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2023, 8:23 AM
miyengar requested review of this revision.Aug 23 2023, 8:23 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 23 2023, 8:23 AM

Sounds good. Can you make sure you upload with context, it makes the patches easier to read in phabricator: https://llvm.org/docs/DeveloperPolicy.html#making-and-submitting-a-patch.

llvm/lib/Target/AArch64/AArch64InstrFormats.td
6297

This looks like it is defining a new instruction. Does that already exist somewhere? Probably from somewhere like FRIntNNT.

miyengar updated this revision to Diff 553104.Aug 24 2023, 6:43 AM
miyengar marked an inline comment as done.Aug 24 2023, 6:49 AM

Thank you for the feedback! I've added an amended patch using the pre-existing instruction. Also, I've tried to submit the patch with context this time.

llvm/lib/Target/AArch64/AArch64InstrFormats.td
6297

Ah thanks! I've amended this to use the already existing instruction (FRINT32ZDr) as defined in FRIntNNT

dmgreen added inline comments.Sep 3 2023, 11:55 PM
llvm/lib/Target/AArch64/AArch64InstrFormats.td
6309

I think the instructions in this multiclass are the vector variants. Can the pattern be moved to the FRIntNNT/SingleOperandFPNo16 class?

miyengar updated this revision to Diff 555879.Sep 5 2023, 9:25 AM
miyengar marked an inline comment as done.

Moved v1f64 -> Dr (Vector to Scalar) Pattern from SIMDTwoVectorSD to FRIntNNTVector

miyengar added inline comments.Sep 5 2023, 9:28 AM
llvm/lib/Target/AArch64/AArch64InstrFormats.td
6309

Thanks for the comment. I have tried to do this, but have run into a problem:

This pattern targets the LLVM internal intrinsic: int_aarch64_neon_frint***_v1f64, as referenced in AArch64InstrInfo.td:

defm FRINT32Z : FRIntNNTVector<0, 0, "frint32z", int_aarch64_neon_frint32z>;

It pattern matches 'v1f64' to 'Dr', which corresponds to a scalar instruction defined in FRIntNNT/SingleOperandFPNo16 - I.e. it is matching the vector variant to the scalar variant.

Moving the pattern to FRIntNNT results in an error "Cannot select: intrinsic %llvm.aarch64.neon.frint64x" as FRIntNNT is designed to match the intrinsics whose name does not contain "neon". Since the current patch deals specifically with the neon variant, I don't see an uncomplicated way to modify FRIntNNT to accommodate both variants of such intrinsic (neon and vanilla).

I have moved the pattern from SIMDTwoVectorSD to FRIntNNTVector though which is hopefully a better place to put it.

Does this seem like a sensible solution? Thanks!

Other than where the pattern gets defined this looks OK to me.

llvm/lib/Target/AArch64/AArch64InstrFormats.td
6309

I see, Because there is a difference between int_aarch64_frint32z and int_aarch64_neon_frint32z.

Could you pass int_aarch64_neon_frint32z to FRIntNNT too, or make them free patterns in AArch64InstrInfo.td? Otherwise this is using the class to generate vector variants of FRINT32Z to also generate the scalar FRINT32ZDr instruction too. It likely doesn't matter a huge amount, but it feels like it breaks the encapsulation of the FRIntNNTVector class.

miyengar updated this revision to Diff 556170.Sep 7 2023, 9:16 AM

Moved pattern from AArchInstrFormats.td to AArchInstrInfo.td

miyengar added inline comments.Sep 7 2023, 9:19 AM
llvm/lib/Target/AArch64/AArch64InstrFormats.td
6309

Ah okay, this makes sense, thank you!

I have moved the patterns from FRIntNNTVector to make them free patterns in AArch64InstrInfo.td instead - this should preserve the encapsulation of the FRIntNNTVector class.

dmgreen accepted this revision.Sep 7 2023, 11:23 PM

Thanks. LGTM

This revision is now accepted and ready to land.Sep 7 2023, 11:23 PM
This revision was landed with ongoing or failed builds.Sep 11 2023, 4:59 AM
Closed by commit rGdbeb3d029d8e: Add missing vrnd intrinsics (authored by miyengar, committed by vhscampos). · Explain Why
This revision was automatically updated to reflect the committed changes.