[PATCH] D99682: [SelectionDAG] Teach SelectionDAG::FoldConstantArithmetic to handle SPLAT_VECTOR
David Sherwood via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 1 01:46:49 PDT 2021
david-arm added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5125
+ // SPLAT_VECTOR or UNDEF are present?
+ unsigned NumOps = VT.isScalableVector() ? 1 : VT.getVectorNumElements();
for (unsigned I = 0; I != NumOps; ++I) {
----------------
I wonder if it makes more sense to only set NumOps to VT.getVectorNumElements() if at least one opcode is BUILD_VECTOR. Then you can have an assert that for scalable vectors neither of the opcodes is BUILD_VECTOR.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5167
+ if (VT.isScalableVector()) {
+ assert(Outputs.size() == 1 && "Vector size mismatch!");
----------------
This is just a suggestion, but instead of checking for scalable vectors, if you change NumOps above to be always be 1 if no BUILD_VECTORs are involved, then maybe you could write:
if (Outputs.size() == 1) {
// Must be a combination of either SPLAT_VECTOR or UNDEF.
return getSplatVector(VT, SDLoc(), Outputs[0]);
}
However, I'm not sure about the case when both inputs are UNDEF and maybe still want to return UNDEF?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99682/new/
https://reviews.llvm.org/D99682
More information about the llvm-commits
mailing list