diff options
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index f877fb6..0358f99 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -1617,39 +1617,6 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C, cast<VectorType>(GEPTy)->getElementCount(), C) : C; - if (C->isNullValue()) { - bool isNull = true; - for (Value *Idx : Idxs) - if (!isa<UndefValue>(Idx) && !cast<Constant>(Idx)->isNullValue()) { - isNull = false; - break; - } - if (isNull) { - PointerType *PtrTy = cast<PointerType>(C->getType()->getScalarType()); - Type *Ty = GetElementPtrInst::getIndexedType(PointeeTy, Idxs); - - assert(Ty && "Invalid indices for GEP!"); - Type *OrigGEPTy = PointerType::get(Ty, PtrTy->getAddressSpace()); - Type *GEPTy = PointerType::get(Ty, PtrTy->getAddressSpace()); - if (VectorType *VT = dyn_cast<VectorType>(C->getType())) - GEPTy = VectorType::get(OrigGEPTy, VT->getElementCount()); - - // The GEP returns a vector of pointers when one of more of - // its arguments is a vector. - for (Value *Idx : Idxs) { - if (auto *VT = dyn_cast<VectorType>(Idx->getType())) { - assert((!isa<VectorType>(GEPTy) || isa<ScalableVectorType>(GEPTy) == - isa<ScalableVectorType>(VT)) && - "Mismatched GEPTy vector types"); - GEPTy = VectorType::get(OrigGEPTy, VT->getElementCount()); - break; - } - } - - return Constant::getNullValue(GEPTy); - } - } - if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) if (auto *GEP = dyn_cast<GEPOperator>(CE)) if (Constant *C = foldGEPOfGEP(GEP, PointeeTy, InBounds, Idxs)) |