This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Enable cross basic block aware writevxrm insertion
AbandonedPublic

Authored by arcbbb on Mar 30 2022, 1:53 AM.

Details

Summary

This patch extends D121376 to allow VXRM changes from predecessors to be taken into account before adding a WriteVXRMImm in a basic block and look for chances to hoist a VXRM change out of a loop.

The limitations of this implementation:

  1. It is based on the assumption that vxrm is call-clobbered, so it no longer saves VXRM for a call.
  2. It only applies the data flow analysis on functions which have no pseudos using dynamic round mode.

Diff Detail

Event Timeline

arcbbb created this revision.Mar 30 2022, 1:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2022, 1:53 AM
arcbbb requested review of this revision.Mar 30 2022, 1:53 AM

Hmm, I think that made the dynamic rounding mode become unexpected/random rounding mode, give following example, the behavior vaddd in foo is unpredictably, vaddd in foo will operated with current rounding mode if the bar is inlined, but it will become rnu once bar inlined, I really think we should restore that for those static rounding mode stuffs.

foo:
  call bar
  vaddd

bar:
  vaadd.rm rnu
arcbbb added a comment.Apr 2 2022, 9:22 AM

Hmm, I think that made the dynamic rounding mode become unexpected/random rounding mode, give following example, the behavior vaddd in foo is unpredictably, vaddd in foo will operated with current rounding mode if the bar is inlined, but it will become rnu once bar inlined, I really think we should restore that for those static rounding mode stuffs.

foo:
  call bar
  vaddd

bar:
  vaadd.rm rnu

The summary mentioned that this assumed that vxrm is call-clobbered,
so in this case after the bar() return , vxrm should be set explicitly before the next vaadd with dynamic round mode.

arcbbb added a comment.Apr 2 2022, 9:41 AM

Hmm, I think that made the dynamic rounding mode become unexpected/random rounding mode, give following example, the behavior vaddd in foo is unpredictably, vaddd in foo will operated with current rounding mode if the bar is inlined, but it will become rnu once bar inlined, I really think we should restore that for those static rounding mode stuffs.

foo:
  call bar
  vaddd

bar:
  vaadd.rm rnu

By the way, in this case vxrm is unknown on foo() entry, it is unpredictable in the first place.

I think that's we treating different view for vxrm, ABI was said same as frm, but now we plan to pull that out due to controversial for now, but I still not convinced for that, we pull out that out for prevent making short-sighted ABI decision, but you go this way means we made decision on close the possibility of venv, and that made dynamic rounding mode more unpredictable IMO.

This way require reset by user instead of restore by compiler, that sound like you push the responsibility back to user, and that what compiler can do, it's really better way to go? I am really suspect for that.

arcbbb added a comment.Apr 3 2022, 8:16 AM

I think that's we treating different view for vxrm, ABI was said same as frm, but now we plan to pull that out due to controversial for now, but I still not convinced for that, we pull out that out for prevent making short-sighted ABI decision, but you go this way means we made decision on close the possibility of venv, and that made dynamic rounding mode more unpredictable IMO.

I want to provide a call-clobbered based implementation for reference to support the idea and hopefully can get some comments & feedback.
I think it will not get merged until the ABI says so. Sorry for the confusion.
About the psABI discussion I would suggest we go https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/256. Thanks.

arcbbb abandoned this revision.Aug 10 2023, 1:39 AM

Close this as D151396 is merged.

evandro removed a subscriber: evandro.Aug 10 2023, 5:49 PM