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

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 10:56:09 PDT 2016


efriedma added a comment.

This approach looks right.



================
Comment at: lib/CodeGen/SelectionDAG/TargetLowering.cpp:3607
+  if (isa<ConstantSDNode>(Idx))
+    return Idx;
+
----------------
I'm pretty sure this special-case isn't safe; just because it's a constant doesn't mean it's in range.


================
Comment at: lib/CodeGen/SelectionDAG/TargetLowering.cpp:3619
+  return DAG.getNode(ISD::UMIN, dl, IdxVT, Idx,
+                     DAG.getConstant(NElts - 1, dl, IdxVT));
+}
----------------
It would be nice if we could round the number of elements up to a power of two... I guess it's not important.


https://reviews.llvm.org/D26174





More information about the llvm-commits mailing list