This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fix vm operand constraint to fit GCC's behavior
ClosedPublic

Authored by kito-cheng on Oct 27 2021, 1:21 AM.

Details

Summary
  • vm constraint is used for masking operand, which always v0.
  • Update testcase, only masking operand should use vm, vector mask operations should just use vr for any vector register.
    • Revise the description of vm constraint.
  • This patch also fix issue on RISCVRegisterInfo.td and RISCVISelLowering.cpp.

    RISCVRegisterInfo.td:
    • The first VT in the list must be the largest total size since the SelectionDAGBuilder uses the first register in the list as the canonical type for the register.

      RISCVISelLowering.cpp:
    • Fix RISCVTargetLowering::splitValueIntoRegisterParts and RISCVTargetLowering::joinRegisterPartsIntoValue for handling vectors with different total size, that will happened on fractional LMUL since fractional LMUL is always occupy one vector register.

Diff Detail

Event Timeline

kito-cheng created this revision.Oct 27 2021, 1:21 AM
kito-cheng requested review of this revision.Oct 27 2021, 1:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2021, 1:21 AM
kito-cheng retitled this revision from Fix vm operand constraint to fit GCC's behavior to [RISCV] Fix vm operand constraint to fit GCC's behavior.Oct 27 2021, 1:23 AM
frasercrmck added inline comments.Oct 27 2021, 3:32 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
9847

The name LargerEltTypeVT, to me anyway, implies it's a vector type with a larger element type when in fact it's a vector with the same element type. Maybe something like WideValueVT?

EDIT: Though that said, in joinRegisterPartsIntoValue you're keeping the name SameEltTypeVT. I'd prefer consistency in whatever we pick.

9851

I realise you're copying this from the existing code but shouldn't we be using DAG.getVectorIdxConstant(0, DL) here?

9854

I'm wondering if we should place braces around this, given the else is a multi-line statement. I think we do that elsewhere.

llvm/lib/Target/RISCV/RISCVRegisterInfo.td
529

Good catch! I'd prefer to properly order them as in VM below though. Which begs the question: why isn't VM using VMaskVTs?

kito-cheng added inline comments.Oct 27 2021, 9:24 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
9851

I'll update what I updated part, and keep untouched for other DAG.getConstant(0, DL, Subtarget.getXLenVT())

kito-cheng marked 4 inline comments as done.
frasercrmck accepted this revision.Oct 28 2021, 2:34 AM

LGTM but I'd prefer to wait a couple of days to give other people a chance to look

This revision is now accepted and ready to land.Oct 28 2021, 2:34 AM
This revision was landed with ongoing or failed builds.Dec 8 2021, 10:47 PM
This revision was automatically updated to reflect the committed changes.