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

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 11:13:01 PDT 2016


efriedma added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/TargetLowering.cpp:3607
+  if (isa<ConstantSDNode>(Idx))
+    return Idx;
+
----------------
arsenm wrote:
> 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
If getNode() is actually enforcing the restriction, fine... otherwise, we're likely to run into issues which are extremely difficult to reproduce because the constant is getting produced by splitting an integer in legalization or something like that.


https://reviews.llvm.org/D26174





More information about the llvm-commits mailing list