Skip to content

[DAG] getNode - assert that INSERT_VECTOR_ELT operand types are legal #143502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7896,7 +7896,18 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
break;
}
case ISD::INSERT_VECTOR_ELT: {
ConstantSDNode *N3C = dyn_cast<ConstantSDNode>(N3);
assert(VT.isVector() && VT == N1.getValueType() &&
"INSERT_VECTOR_ELT vector type mismatch");
assert(VT.isFloatingPoint() == N2.getValueType().isFloatingPoint() &&
"INSERT_VECTOR_ELT scalar fp/int mismatch");
assert((!VT.isFloatingPoint() ||
VT.getVectorElementType() == N2.getValueType()) &&
"INSERT_VECTOR_ELT fp scalar type mismatch");
assert((!VT.isInteger() ||
VT.getScalarSizeInBits() <= N2.getScalarValueSizeInBits()) &&
"INSERT_VECTOR_ELT int scalar size mismatch");

auto *N3C = dyn_cast<ConstantSDNode>(N3);
// INSERT_VECTOR_ELT into out-of-bounds element is an UNDEF, except
// for scalable vectors where we will generate appropriate code to
// deal with out-of-bounds cases correctly.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22234,7 +22234,7 @@ SDValue X86TargetLowering::LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const {
} else {
In = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i32, In);
In = DAG.getNode(ISD::INSERT_VECTOR_ELT, DL, MVT::v4i32,
DAG.getUNDEF(MVT::v4f32), In,
DAG.getUNDEF(MVT::v4i32), In,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

DAG.getVectorIdxConstant(0, DL));
In = DAG.getBitcast(MVT::v8i16, In);
Res = DAG.getNode(X86ISD::CVTPH2PS, DL, MVT::v4f32, In,
Expand Down
Loading