This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Improve the condition of hasRVVFrameObject.
Needs ReviewPublic

Authored by jacquesguan on Jan 24 2022, 3:34 AM.

Details

Summary

Now the function hasRVVFrameObject is using hasVInstructions() as the return value. This patch changed it to two parts judgement. Firstly, check if there is any frame object that is scalable vector. If there is no scalable vector frame object, then check if there is any V instruction in the function.

Diff Detail

Event Timeline

jacquesguan created this revision.Jan 24 2022, 3:34 AM
jacquesguan requested review of this revision.Jan 24 2022, 3:34 AM

Is it possible write a test for this?

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
951–952

Does this comment need to be updated?

Add test case and update the comment.

Is it possible write a test for this?

I add a case to show the difference when the function will not use any rvv.

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
951–952

Done.

craig.topper added inline comments.Feb 9 2022, 6:25 PM
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
976

Is it possible to write a function that contains nothing but whole register loads/stores/moves such that no instruction access VL but needs to spill a register?

jacquesguan added inline comments.Feb 14 2022, 10:51 PM
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
976

I am not sure about this, I think maybe it's not possible to generate independent whole register instructions. Do you have any good opinion about the condition?

kito-cheng added inline comments.Feb 14 2022, 11:05 PM
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
976

Maybe check any vector register are appear in the function either use or def?

craig.topper added inline comments.Feb 14 2022, 11:17 PM
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
976

This generates a single whole register load

#include <riscv_vector.h>

vfloat32m4_t foo(vfloat32m4_t *a) {
  return *a;
}
craig.topper added inline comments.Feb 14 2022, 11:19 PM
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
976

That was only meant as an example of how register instrutions can be generated. Not that it creates scalable frame object.

Address comment.

jacquesguan added inline comments.Feb 15 2022, 11:58 PM
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
976

Done, I changed the condition to check if there ia any VR or VTYPE.

craig.topper added inline comments.Apr 12 2022, 10:22 AM
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
965

This sentence doesn't make sense. Isn't this checking for the existence of an RVV frame object directly?

978

Does RISCV::VRRegClass.contains work for virtual registers?

jacquesguan added inline comments.Apr 13 2022, 2:10 AM
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
978

NO, what do you think is a good way to check if there is any VR?

craig.topper added inline comments.Apr 13 2022, 9:34 AM
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
978

I think using MachineRegisterInfo::getRegClass