From bdb8db458917cd3d6a0b1d9dd67cb86748c052fb Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 10 Nov 2017 23:36:56 +0000 Subject: [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. llvm-svn: 317950 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 285f7eba099..e0155e73f55 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -3884,10 +3884,11 @@ static bool getUniformBase(const Value* &Ptr, SDValue& Base, SDValue& Index, Value *IndexVal = GEP->getOperand(FinalIndex); // Ensure all the other indices are 0. - for (unsigned i = 1; i < FinalIndex; ++i) - if (auto *C = dyn_cast(GEP->getOperand(i))) - if (!C->isZero()) - return false; + for (unsigned i = 1; i < FinalIndex; ++i) { + auto *C = dyn_cast(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. -- cgit v1.2.3