This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Do not use FPR registers for fastcc if zfh/f/d is not specified in the architecture
ClosedPublic

Authored by eopXD on Jul 17 2023, 11:29 AM.

Details

Summary

Resolves #63917.

Also lets the compiler check for available GPR before hitting the stack.

Diff Detail

Event Timeline

eopXD created this revision.Jul 17 2023, 11:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2023, 11:29 AM
eopXD requested review of this revision.Jul 17 2023, 11:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2023, 11:29 AM
craig.topper added inline comments.Jul 17 2023, 11:32 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
15194

I think you meant Zfh? But even then you probably mean Zfh || Zfhmin?

eopXD updated this revision to Diff 541159.Jul 17 2023, 11:38 AM
eopXD marked an inline comment as done.

Add test case and fix if-condition for f16.

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
15194

Yes indeed, I keep mistaking them. Thank you for correcting me.

craig.topper added inline comments.Jul 17 2023, 11:42 AM
llvm/test/CodeGen/RISCV/fastcc-without-f-reg.ll
8

Drop dso_local and local_unnamed_addr. but add nowind

eopXD updated this revision to Diff 541164.Jul 17 2023, 11:45 AM

Improve test case

  • Drop dso_local and local_unnamed_addr. but add nowind
  • Add test case for zdinx
eopXD marked an inline comment as done.Jul 17 2023, 11:45 AM
craig.topper added inline comments.Jul 17 2023, 12:05 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
15243

If we skip the FPRs above, should we be going through GPR before we hit this stack code?

eopXD updated this revision to Diff 541183.Jul 17 2023, 12:23 PM

Let the compiler check for available GPR-s before hitting the spec.

eopXD edited the summary of this revision. (Show Details)Jul 17 2023, 12:24 PM
eopXD marked an inline comment as done.
craig.topper retitled this revision from [RISCV] Do not use F registers if zvfh/f/d is not specified in the architecture to [RISCV] Do not use FPR registers for fastcc if zfh/f/d is not specified in the architecture.Jul 17 2023, 12:37 PM
craig.topper added a reviewer: asb.
asb accepted this revision.Jul 17 2023, 1:15 PM

LGTM.

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
15231

nit: end with full stop and "an available".

This revision is now accepted and ready to land.Jul 17 2023, 1:15 PM
eopXD updated this revision to Diff 541379.EditedJul 18 2023, 1:07 AM
eopXD marked an inline comment as done.

Fix if-condition, use GPR register when zhinx/zfinx/zdinx is available.