This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Change how we encode AVL operands in vector pseudoinstructions to use GPRNoX0.
ClosedPublic

Authored by craig.topper on Sep 1 2021, 5:49 PM.

Details

Summary

This patch changes the register class to avoid accidentally setting
the AVL operand to X0 through MachineIR optimizations.

There are cases where we really want to use X0, but we can't get that
past the MachineVerifier with the register class as GPRNoX0. So I've
use a 64-bit -1 as a sentinel for X0. All other immediate values should
be uimm5. I convert it to X0 at the earliest possible point in the VSETVLI
insertion pass to avoid touching the rest of the algorithm. In
SelectionDAG lowering I'm using a -1 TargetConstant to hide it from
instruction selection and treat it differently than if the user
used -1. A user -1 should be selected to a register since it doesn't
fit in uimm5.

This is the rest of the changes started in D109110. As mentioned there,
I don't have a failing test from MachineIR optimizations anymore.

Diff Detail

Event Timeline

craig.topper created this revision.Sep 1 2021, 5:49 PM
craig.topper requested review of this revision.Sep 1 2021, 5:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2021, 5:49 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

Neat trick!

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

I think this sentinel may be better served as a named constant in C++. Doesn't really help the two uses in TableGen though.

Add named constant for the sentinel.

clang-format

frasercrmck accepted this revision.Sep 3 2021, 6:21 AM

LGTM - thanks!

This revision is now accepted and ready to land.Sep 3 2021, 6:21 AM