Skip to content

Commit

Permalink
[RISCV] Teach fillUpExtensionSupportForSplat to handle nxvXi64 VMV_V_…
Browse files Browse the repository at this point in the history
…X_VL on RV32. (#99251)

A nxvXi64 VMV_V_X_VL on RV32 sign extends its 32 bit input to 64 bits.
If that input is positive, the sign extend can also be considered as a
zero extend.
  • Loading branch information
topperc authored Jul 17, 2024
1 parent a51f343 commit d85f105
Show file tree
Hide file tree
Showing 16 changed files with 824 additions and 1,166 deletions.
17 changes: 14 additions & 3 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14503,10 +14503,21 @@ struct NodeExtensionHelper {
// widening opcode by splatting to smaller element size.
unsigned EltBits = VT.getScalarSizeInBits();
unsigned ScalarBits = Op.getValueSizeInBits();
// Make sure we're getting all element bits from the scalar register.
// FIXME: Support implicit sign extension of vmv.v.x?
if (ScalarBits < EltBits)
// If we're not getting all bits from the element, we need special handling.
if (ScalarBits < EltBits) {
// This should only occur on RV32.
assert(Opc == RISCVISD::VMV_V_X_VL && EltBits == 64 && ScalarBits == 32 &&
!Subtarget.is64Bit() && "Unexpected splat");
// vmv.v.x sign extends narrow inputs.
SupportsSExt = true;

// If the input is positive, then sign extend is also zero extend.
if (DAG.SignBitIsZero(Op))
SupportsZExt = true;

EnforceOneUse = false;
return;
}

unsigned NarrowSize = EltBits / 2;
// If the narrow type cannot be expressed with a legal VMV,
Expand Down
Loading

0 comments on commit d85f105

Please sign in to comment.