diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 397254b8855d2f..fed02b47cf2c32 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4424,16 +4424,9 @@ static bool getUniformBase(const Value *&Ptr, SDValue &Base, SDValue &Index, if (STy) { const StructLayout *SL = DL.getStructLayout(STy); - if (isa(C->getType())) { - C = C->getSplatValue(); - // FIXME: If getSplatValue may return nullptr for a structure? - // If not, the following check can be removed. - if (!C) - return false; - } - auto *CI = cast(C); + unsigned Field = cast(IndexVal)->getUniqueInteger().getZExtValue(); Scale = DAG.getTargetConstant(1, SDB->getCurSDLoc(), TLI.getPointerTy(DL)); - Index = DAG.getConstant(SL->getElementOffset(CI->getZExtValue()), + Index = DAG.getConstant(SL->getElementOffset(Field), SDB->getCurSDLoc(), TLI.getPointerTy(DL)); } else { Scale = DAG.getTargetConstant(