[GISel][RISCV] Correctly handle scalable vector shuffles of pointer vectors in IRTranslator. (#106580)
This commit is contained in:
parent
59762a0ecf
commit
d5c292d8ef
@ -3183,15 +3183,14 @@ bool IRTranslator::translateExtractElement(const User &U,
|
|||||||
|
|
||||||
bool IRTranslator::translateShuffleVector(const User &U,
|
bool IRTranslator::translateShuffleVector(const User &U,
|
||||||
MachineIRBuilder &MIRBuilder) {
|
MachineIRBuilder &MIRBuilder) {
|
||||||
// A ShuffleVector that has operates on scalable vectors is a splat vector
|
// A ShuffleVector that operates on scalable vectors is a splat vector where
|
||||||
// where the value of the splat vector is the 0th element of the first
|
// the value of the splat vector is the 0th element of the first operand,
|
||||||
// operand, since the index mask operand is the zeroinitializer (undef and
|
// since the index mask operand is the zeroinitializer (undef and
|
||||||
// poison are treated as zeroinitializer here).
|
// poison are treated as zeroinitializer here).
|
||||||
if (U.getOperand(0)->getType()->isScalableTy()) {
|
if (U.getOperand(0)->getType()->isScalableTy()) {
|
||||||
Value *Op0 = U.getOperand(0);
|
Register Val = getOrCreateVReg(*U.getOperand(0));
|
||||||
auto SplatVal = MIRBuilder.buildExtractVectorElementConstant(
|
auto SplatVal = MIRBuilder.buildExtractVectorElementConstant(
|
||||||
LLT::scalar(Op0->getType()->getScalarSizeInBits()),
|
MRI->getType(Val).getElementType(), Val, 0);
|
||||||
getOrCreateVReg(*Op0), 0);
|
|
||||||
MIRBuilder.buildSplatVector(getOrCreateVReg(U), SplatVal);
|
MIRBuilder.buildSplatVector(getOrCreateVReg(U), SplatVal);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1835,8 +1835,8 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SrcTy.isScalar()) {
|
if (!SrcTy.isScalar() && !SrcTy.isPointer()) {
|
||||||
report("Source type must be a scalar", MI);
|
report("Source type must be a scalar or pointer", MI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1770,5 +1770,24 @@ define <vscale x 16 x i64> @shufflevector_nxv16i64_2(<vscale x 16 x i64> %a) {
|
|||||||
ret <vscale x 16 x i64> %b
|
ret <vscale x 16 x i64> %b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define <vscale x 1 x ptr> @shufflevector_nxv1p0_0() {
|
||||||
|
; RV32-LABEL: name: shufflevector_nxv1p0_0
|
||||||
|
; RV32: bb.1 (%ir-block.0):
|
||||||
|
; RV32-NEXT: [[DEF:%[0-9]+]]:_(<vscale x 1 x p0>) = G_IMPLICIT_DEF
|
||||||
|
; RV32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
|
||||||
|
; RV32-NEXT: [[EVEC:%[0-9]+]]:_(p0) = G_EXTRACT_VECTOR_ELT [[DEF]](<vscale x 1 x p0>), [[C]](s32)
|
||||||
|
; RV32-NEXT: [[SPLAT_VECTOR:%[0-9]+]]:_(<vscale x 1 x p0>) = G_SPLAT_VECTOR [[EVEC]](p0)
|
||||||
|
; RV32-NEXT: $v8 = COPY [[SPLAT_VECTOR]](<vscale x 1 x p0>)
|
||||||
|
; RV32-NEXT: PseudoRET implicit $v8
|
||||||
|
;
|
||||||
|
; RV64-LABEL: name: shufflevector_nxv1p0_0
|
||||||
|
; RV64: bb.1 (%ir-block.0):
|
||||||
|
; RV64-NEXT: [[DEF:%[0-9]+]]:_(<vscale x 1 x p0>) = G_IMPLICIT_DEF
|
||||||
|
; RV64-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
|
||||||
|
; RV64-NEXT: [[EVEC:%[0-9]+]]:_(p0) = G_EXTRACT_VECTOR_ELT [[DEF]](<vscale x 1 x p0>), [[C]](s64)
|
||||||
|
; RV64-NEXT: [[SPLAT_VECTOR:%[0-9]+]]:_(<vscale x 1 x p0>) = G_SPLAT_VECTOR [[EVEC]](p0)
|
||||||
|
; RV64-NEXT: $v8 = COPY [[SPLAT_VECTOR]](<vscale x 1 x p0>)
|
||||||
|
; RV64-NEXT: PseudoRET implicit $v8
|
||||||
|
%a = shufflevector <vscale x 1 x ptr> poison, <vscale x 1 x ptr> poison, <vscale x 1 x i32> zeroinitializer
|
||||||
|
ret <vscale x 1 x ptr> %a
|
||||||
|
}
|
||||||
|
@ -16,10 +16,10 @@ body: |
|
|||||||
; CHECK: Destination type must be a scalable vector
|
; CHECK: Destination type must be a scalable vector
|
||||||
%4:_(<2 x s32>) = G_SPLAT_VECTOR %0
|
%4:_(<2 x s32>) = G_SPLAT_VECTOR %0
|
||||||
|
|
||||||
; CHECK: Source type must be a scalar
|
; CHECK: Source type must be a scalar or pointer
|
||||||
%5:_(<vscale x 2 x s32>) = G_SPLAT_VECTOR %1
|
%5:_(<vscale x 2 x s32>) = G_SPLAT_VECTOR %1
|
||||||
|
|
||||||
; CHECK: Source type must be a scalar
|
; CHECK: Source type must be a scalar or pointer
|
||||||
%6:_(<vscale x 2 x s32>) = G_SPLAT_VECTOR %2
|
%6:_(<vscale x 2 x s32>) = G_SPLAT_VECTOR %2
|
||||||
|
|
||||||
; CHECK: Element type of the destination must be the same size or smaller than the source type
|
; CHECK: Element type of the destination must be the same size or smaller than the source type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user