This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fix assertion when passing f64 vectors via integer registers
ClosedPublic

Authored by wangpc on Aug 14 2023, 2:23 AM.

Details

Summary

The vector arguments are split but assignments won't be pending.

Fixes #64645

Diff Detail

Event Timeline

wangpc created this revision.Aug 14 2023, 2:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 2:23 AM
wangpc requested review of this revision.Aug 14 2023, 2:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 2:23 AM
asb accepted this revision.Aug 14 2023, 3:45 AM

LGTM (thanks!) with a minor modification: please extend the test case so the argument is actually accessed (by adding a new function or otherwise).

e.g. define <2 x double> @v2f64(<2 x double> %x, <2 x double> %y) { and %1 = fadd <2 x double> %x, %y; ret <2 x double> %1

Such a test also demonstrates that atrociously poor code is generated in that case (copying arguments to and from the stack unnecessarily). It does seem to be correct though. I suspect more attention is needed for zdinx code quality.

One point to note is that if whatever frontend that generated this code is aiming to comply with the standard calling convention, it should be passing that vector in memory (as Clang does).

This revision is now accepted and ready to land.Aug 14 2023, 3:45 AM
asb added a comment.Aug 14 2023, 3:47 AM

Oh, and please add "Fixes #64645" or similar to the commit message.

liaolucy added inline comments.
llvm/test/CodeGen/RISCV/pr64645.ll
9

I have a question, do I need to load and store from the stack here?

eg:
        lw      a2, 12(a1)
        lw      a3, 8(a1)
        lw      a4, 4(a1)
        lw      a1, 0(a1)
        sw      a2, 12(a0)
        sw      a3, 8(a0)
        sw      a4, 4(a0)
        sw      a1, 0(a0)
wangpc updated this revision to Diff 549868.Aug 14 2023, 4:05 AM

Update test.

wangpc edited the summary of this revision. (Show Details)Aug 14 2023, 4:06 AM
wangpc marked an inline comment as done.Aug 14 2023, 4:11 AM
wangpc added inline comments.
llvm/test/CodeGen/RISCV/pr64645.ll
9

The previous test can generate load/store after ISel but these load/store will be deleted during RA as they are not used.
As @asb suggested, I added some operations on arguments so the lowering of arguments will be visible.

asb added inline comments.Aug 14 2023, 6:18 AM
llvm/test/CodeGen/RISCV/pr64645.ll
6

Nit: we'd normally at nounwind here as there's nothing we're specifically trying to test about the .cfi stuff.

wangpc updated this revision to Diff 550184.Aug 14 2023, 8:42 PM
wangpc marked an inline comment as done.

Add nounwind.

This revision was landed with ongoing or failed builds.Aug 14 2023, 9:12 PM
This revision was automatically updated to reflect the committed changes.