[PATCH] D26174: DAG: Avoid OOB when legalizing vector indexing

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 11:03:10 PDT 2016


arsenm added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/TargetLowering.cpp:3607
+  if (isa<ConstantSDNode>(Idx))
+    return Idx;
+
----------------
efriedma wrote:
> I'm pretty sure this special-case isn't safe; just because it's a constant doesn't mean it's in range.
I was wondering about this, however I think it's OK. getNode for EXTRACT_VECTOR_ELT turns this into undef for out of bounds. For INSERT_VECTOR_ELT it seems to not, but I also haven't been able to come up  with a testcase where this gets hit


================
Comment at: lib/CodeGen/SelectionDAG/TargetLowering.cpp:3619
+  return DAG.getNode(ISD::UMIN, dl, IdxVT, Idx,
+                     DAG.getConstant(NElts - 1, dl, IdxVT));
+}
----------------
efriedma wrote:
> It would be nice if we could round the number of elements up to a power of two... I guess it's not important.
This should probably be an assert for now since I think this only happens after vector type legalization. When 3-vectors are eventually added this will need to be handled


https://reviews.llvm.org/D26174





More information about the llvm-commits mailing list