Skip to content

Commit fcfc8e2

Browse files
toppercyuxuanchen1997
authored andcommitted
[RISCV] Teach fillUpExtensionSupportForSplat to handle nxvXi64 VMV_V_X_VL on RV32. (#99251)
Summary: 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. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250893
1 parent d1cca72 commit fcfc8e2

16 files changed

+824
-1166
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14503,10 +14503,21 @@ struct NodeExtensionHelper {
1450314503
// widening opcode by splatting to smaller element size.
1450414504
unsigned EltBits = VT.getScalarSizeInBits();
1450514505
unsigned ScalarBits = Op.getValueSizeInBits();
14506-
// Make sure we're getting all element bits from the scalar register.
14507-
// FIXME: Support implicit sign extension of vmv.v.x?
14508-
if (ScalarBits < EltBits)
14506+
// If we're not getting all bits from the element, we need special handling.
14507+
if (ScalarBits < EltBits) {
14508+
// This should only occur on RV32.
14509+
assert(Opc == RISCVISD::VMV_V_X_VL && EltBits == 64 && ScalarBits == 32 &&
14510+
!Subtarget.is64Bit() && "Unexpected splat");
14511+
// vmv.v.x sign extends narrow inputs.
14512+
SupportsSExt = true;
14513+
14514+
// If the input is positive, then sign extend is also zero extend.
14515+
if (DAG.SignBitIsZero(Op))
14516+
SupportsZExt = true;
14517+
14518+
EnforceOneUse = false;
1450914519
return;
14520+
}
1451014521

1451114522
unsigned NarrowSize = EltBits / 2;
1451214523
// If the narrow type cannot be expressed with a legal VMV,

0 commit comments

Comments
 (0)