-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Open
Labels
good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributellvm:SelectionDAGSelectionDAGISel as wellSelectionDAGISel as well
Description
As discussed here: #171459 (comment)
llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h
Lines 100 to 109 in 578a26a
| /// Return a VT for a vector type whose attributes match ourselves | |
| /// with the exception of the element type that is chosen by the caller. | |
| EVT changeVectorElementType(EVT EltVT) const { | |
| if (isSimple()) { | |
| assert(EltVT.isSimple() && | |
| "Can't change simple vector VT to have extended element VT"); | |
| return getSimpleVT().changeVectorElementType(EltVT.getSimpleVT()); | |
| } | |
| return changeExtendedVectorElementType(EltVT); | |
| } |
The problem is if the original vector was simple (e.g. v512i32) - but you change it to one that isn't (e.g. v512i64) - MVT::changeVectorElementType is called and will assert internally:
llvm-project/llvm/include/llvm/CodeGenTypes/MachineValueType.h
Lines 211 to 218 in 578a26a
| /// Return a VT for a vector type whose attributes match ourselves | |
| /// with the exception of the element type that is chosen by the caller. | |
| MVT changeVectorElementType(MVT EltVT) const { | |
| MVT VecTy = MVT::getVectorVT(EltVT, getVectorElementCount()); | |
| assert(VecTy.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE && | |
| "Simple vector VT not representable by simple integer vector VT!"); | |
| return VecTy; | |
| } |
Ideally we'd do something similar to EVT::getVectorVT, check for MVT::INVALID_SIMPLE_VALUE_TYPE and fallback to changeExtendedVectorElementType if necessary.
This would then allow quite a few EVT::getVectorVT uses in DAGCombine etc. to be simplified to call EVT::changeElementType or EVT::changeVectorElementType directly without fear of an assert
Metadata
Metadata
Assignees
Labels
good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributellvm:SelectionDAGSelectionDAGISel as wellSelectionDAGISel as well