Skip to content

Commit 5324708

Browse files
Address review comments
1 parent f3f6e57 commit 5324708

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7040,11 +7040,9 @@ SDValue DAGTypeLegalizer::WidenVecOp_INSERT_SUBVECTOR(SDNode *N) {
70407040
SDValue SubVec = N->getOperand(1);
70417041
SDValue InVec = N->getOperand(0);
70427042

7043-
EVT OrigVT;
7044-
if (getTypeAction(SubVec.getValueType()) == TargetLowering::TypeWidenVector) {
7045-
OrigVT = SubVec.getValueType();
7043+
EVT OrigVT = SubVec.getValueType();
7044+
if (getTypeAction(SubVec.getValueType()) == TargetLowering::TypeWidenVector)
70467045
SubVec = GetWidenedVector(SubVec);
7047-
}
70487046

70497047
EVT SubVT = SubVec.getValueType();
70507048

@@ -7067,23 +7065,28 @@ SDValue DAGTypeLegalizer::WidenVecOp_INSERT_SUBVECTOR(SDNode *N) {
70677065
}
70687066
}
70697067

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

7076+
if (!IndicesValid || OrigVT.isScalableVector())
7077+
report_fatal_error(
7078+
"Don't know how to widen the operands for INSERT_SUBVECTOR");
7079+
70767080
// If the operands can't be widened legally, just replace the INSERT_SUBVECTOR
70777081
// with a series of INSERT_VECTOR_ELT
70787082
unsigned Idx = N->getConstantOperandVal(2);
70797083

70807084
SDValue InsertElt = InVec;
7081-
SDLoc DL(N);
70827085
EVT VectorIdxTy = TLI.getVectorIdxTy(DAG.getDataLayout());
7083-
for (unsigned I = 0; I < OrigVT.getVectorNumElements(); ++I) {
7086+
for (unsigned I = 0, E = OrigVT.getVectorNumElements(); I != E; ++I) {
70847087
SDValue ExtractElt =
7085-
DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT.getScalarType(), SubVec,
7086-
DAG.getConstant(I, DL, VectorIdxTy));
7088+
DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT.getVectorElementType(),
7089+
SubVec, DAG.getConstant(I, DL, VectorIdxTy));
70877090
InsertElt =
70887091
DAG.getNode(ISD::INSERT_VECTOR_ELT, DL, VT, InsertElt, ExtractElt,
70897092
DAG.getConstant(I + Idx, DL, VectorIdxTy));

llvm/test/CodeGen/X86/pr124255.ll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
22
; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s
33

4-
define <4 x i32> @insert_i32_v2_in_v4_at_0(<4 x i32> %a, <2 x i32> %b) {
5-
; CHECK-LABEL: insert_i32_v2_in_v4_at_0:
4+
define <4 x i32> @insert_v2i32_in_v4i32_at_0(<4 x i32> %a, <2 x i32> %b) {
5+
; CHECK-LABEL: insert_v2i32_in_v4i32_at_0:
66
; CHECK: # %bb.0:
77
; CHECK-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
88
; CHECK-NEXT: retq
99
%result = tail call <4 x i32> @llvm.vector.insert.v4i32.v2i32(<4 x i32> %a, <2 x i32> %b, i64 0)
1010
ret <4 x i32> %result
1111
}
1212

13-
define <4 x i32> @insert_i32_v2_in_v4_at_2(<4 x i32> %a, <2 x i32> %b) {
14-
; CHECK-LABEL: insert_i32_v2_in_v4_at_2:
13+
define <4 x i32> @insert_v2i32_in_v4i32_at_2(<4 x i32> %a, <2 x i32> %b) {
14+
; CHECK-LABEL: insert_v2i32_in_v4i32_at_2:
1515
; CHECK: # %bb.0:
1616
; CHECK-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1717
; CHECK-NEXT: retq
1818
%result = tail call <4 x i32> @llvm.vector.insert.v4i32.v2i32(<4 x i32> %a, <2 x i32> %b, i64 2)
1919
ret <4 x i32> %result
2020
}
2121

22-
define <4 x float> @insert_f32_v2_in_v4_at_0(<4 x float> %a, <2 x float> %b) {
23-
; CHECK-LABEL: insert_f32_v2_in_v4_at_0:
22+
define <4 x float> @insert_v2f32_in_v4f32_at_0(<4 x float> %a, <2 x float> %b) {
23+
; CHECK-LABEL: insert_v2f32_in_v4f32_at_0:
2424
; CHECK: # %bb.0:
2525
; CHECK-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
2626
; CHECK-NEXT: retq
2727
%result = tail call <4 x float> @llvm.vector.insert.v4float.v2float(<4 x float> %a, <2 x float> %b, i64 0)
2828
ret <4 x float> %result
2929
}
3030

31-
define <8 x i32> @insert_i32_v2_in_v8_at_0(<8 x i32> %a, <2 x i32> %b) {
32-
; CHECK-LABEL: insert_i32_v2_in_v8_at_0:
31+
define <8 x i32> @insert_v2i32_in_v8i32_at_0(<8 x i32> %a, <2 x i32> %b) {
32+
; CHECK-LABEL: insert_v2i32_in_v8i32_at_0:
3333
; CHECK: # %bb.0:
3434
; CHECK-NEXT: movsd {{.*#+}} xmm0 = xmm2[0],xmm0[1]
3535
; CHECK-NEXT: retq
3636
%result = tail call <8 x i32> @llvm.vector.insert.v8i32.v2i32(<8 x i32> %a, <2 x i32> %b, i64 0)
3737
ret <8 x i32> %result
3838
}
3939

40-
define <8 x i32> @insert_i32_v2_in_v8_at_6(<8 x i32> %a, <2 x i32> %b) {
41-
; CHECK-LABEL: insert_i32_v2_in_v8_at_6:
40+
define <8 x i32> @insert_v2i32_in_v8i32_at_6(<8 x i32> %a, <2 x i32> %b) {
41+
; CHECK-LABEL: insert_v2i32_in_v8i32_at_6:
4242
; CHECK: # %bb.0:
4343
; CHECK-NEXT: movlhps {{.*#+}} xmm1 = xmm1[0],xmm2[0]
4444
; CHECK-NEXT: retq

0 commit comments

Comments
 (0)