[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 08:44:18 PDT 2021


david-arm added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5167
 
+  if (VT.isScalableVector()) {
+    assert(Outputs.size() == 1 && "Vector size mismatch!");
----------------
craig.topper wrote:
> david-arm wrote:
> > 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?
> Both inputs being undef doesn't go through this code, it's handled earlier. One of the operands must be a build_vector or splat_vector.
> 
> I think using Outputs.size() == 1 would be incorrect if the fixed vector type has 1 element and the input is build_vector. We shouldn't generate splat_vector in that case.
Ah ok, fair enough. I was just thinking that it might be nice to avoid tying scalable vectors to SPLAT_VECTOR that's all, given that your changes above should work for fixed-length vectors too. For example, if we've already gone to the trouble of creating inputs for fixed-length vectors, then it might make sense to generate one here too?


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