Skip to content

Commit b3257c3

Browse files
committed
[LegalizeVectorTypes] Allow non-undef vectors when widening insert_subvector op
When widening an insert_subvector operand there's currently a restriction that the vector being inserted into has to be undef. It looks like this is just a conservative restriction from when it was first added: https://reviews.llvm.org/D102501 Nothing comes to mind as to why we can't allow non-undef vectors. Fixes #114900
1 parent 3a26feb commit b3257c3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7066,7 +7066,7 @@ SDValue DAGTypeLegalizer::WidenVecOp_INSERT_SUBVECTOR(SDNode *N) {
70667066

70677067
// We need to make sure that the indices are still valid, otherwise we might
70687068
// widen what was previously well-defined to something undefined.
7069-
if (IndicesValid && InVec.isUndef() && N->getConstantOperandVal(2) == 0)
7069+
if (IndicesValid && N->getConstantOperandVal(2) == 0)
70707070
return DAG.getNode(ISD::INSERT_SUBVECTOR, SDLoc(N), VT, InVec, SubVec,
70717071
N->getOperand(2));
70727072

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-insert-subvector.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,3 +1000,12 @@ define <4 x i32> @insert_extract_v8i32_v2i32_0(<2 x i32> %v) {
10001000
%2 = call <4 x i32> @llvm.vector.extract.v4i32.v8i32(<8 x i32> %1, i64 0)
10011001
ret <4 x i32> %2
10021002
}
1003+
1004+
define <vscale x 24 x i8> @insert_nxv24i8_v48i8_0(<vscale x 24 x i8> %v, <48 x i8> %w) vscale_range(2) {
1005+
; CHECK-LABEL: insert_nxv24i8_v48i8_0:
1006+
; CHECK: # %bb.0:
1007+
; CHECK-NEXT: vmv4r.v v8, v12
1008+
; CHECK-NEXT: ret
1009+
%x = call <vscale x 24 x i8> @llvm.vector.insert.v48i8.nxv24i8(<vscale x 24 x i8> %v, <48 x i8> %w, i64 0)
1010+
ret <vscale x 24 x i8> %x
1011+
}

0 commit comments

Comments
 (0)