[llvm] r317950 - [SelectionDAG] Make getUniformBase in SelectionDAGBuilder fail if any of the middle GEP indices are non-constant.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 15:36:56 PST 2017


Author: ctopper
Date: Fri Nov 10 15:36:56 2017
New Revision: 317950

URL: http://llvm.org/viewvc/llvm-project?rev=317950&view=rev
Log:
[SelectionDAG] Make getUniformBase in SelectionDAGBuilder fail if any of the middle GEP indices are non-constant.

This is a fix for a bug in r317947. We were supposed to check that all the indices are are constant 0, but instead we're only make sure that indices that are constant are 0. Non-constant indices are being ignored.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=317950&r1=317949&r2=317950&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Nov 10 15:36:56 2017
@@ -3884,10 +3884,11 @@ static bool getUniformBase(const Value*
   Value *IndexVal = GEP->getOperand(FinalIndex);
 
   // Ensure all the other indices are 0.
-  for (unsigned i = 1; i < FinalIndex; ++i)
-    if (auto *C = dyn_cast<ConstantInt>(GEP->getOperand(i)))
-      if (!C->isZero())
-        return false;
+  for (unsigned i = 1; i < FinalIndex; ++i) {
+    auto *C = dyn_cast<ConstantInt>(GEP->getOperand(i));
+    if (!C || !C->isZero())
+      return false;
+  }
 
   // The operands of the GEP may be defined in another basic block.
   // In this case we'll not find nodes for the operands.




More information about the llvm-commits mailing list