[PATCH] D37880: Fix an out-of-bounds shufflevector index bug

Jatin Bhateja via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 03:06:24 PDT 2017


jbhateja added a comment.

I propose following as the fix , Simon and other reviews can comment.

diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index f81a144de82..f4b5befb49f 100644

- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -14361,7 +14361,8 @@ SDValue DAGCombiner::createBuildVecShuffle(const SDLoc &DL, SDNode *N,

  if (VectorMask[i] <= 0)
    continue;

- unsigned ExtIndex = N->getOperand(i).getConstantOperandVal(1);

+    unsigned ExtIndex = (N->getOperand(i).getConstantOperandVal(1)
+                         % InVT1.getVectorNumElements());

  if (VectorMask[i] == (int)LeftIdx) {
    Mask[i] = ExtIndex;
  } else if (VectorMask[i] == (int)LeftIdx + 1) {


https://reviews.llvm.org/D37880





More information about the llvm-commits mailing list