This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Support i32 clmul* intrinsics on RV64.
ClosedPublic

Authored by craig.topper on Jul 7 2023, 10:51 AM.

Details

Summary

We can use an i64 clmul to emulate i32 clmul.
For clmulh and clmulr we need to zero extend the 32 bit input
to 64 bits then extract either bits [63:32] or [62:31].

Unfortunately, without Zba we need to use 2 shifts for the
zero extends. These can be optimized out later if the producing
instruction already zeroed the upper bits or if we can use lwu.

There are alternative sequences we can use for clmulh/clmulr
when the zero extend isn't free, but those are best handled by
a DAG combine to give the best opportunity for removing the extend.

This allows us to implement i32 clmul C intrinsics proposed in
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/44.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 7 2023, 10:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 10:51 AM
craig.topper requested review of this revision.Jul 7 2023, 10:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 10:51 AM
asb accepted this revision.Jul 14 2023, 11:04 AM

LGTM.

This revision is now accepted and ready to land.Jul 14 2023, 11:04 AM
This revision was landed with ongoing or failed builds.Jul 14 2023, 11:20 AM
This revision was automatically updated to reflect the committed changes.