From: Nikita Popov Date: Wed, 5 Apr 2023 13:02:02 +0000 (+0200) Subject: [InstCombine] Use CreateGEP() API (NFC) X-Git-Tag: upstream/17.0.6~12606 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=53280dba83afc6a23a808b4429ed1e026664bfba;p=platform%2Fupstream%2Fllvm.git [InstCombine] Use CreateGEP() API (NFC) Use the IRBuilder API that accepts inbounds as a boolean parameter, rather than using a ternary. --- diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 7cae08d..116e6b2 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2043,13 +2043,11 @@ Instruction *InstCombinerImpl::visitGEPOfGEP(GetElementPtrInst &GEP, // If both GEP are constant-indexed, and cannot be merged in either way, // convert them to a GEP of i8. if (Src->hasAllConstantIndices()) - return isMergedGEPInBounds(*Src, *cast(&GEP)) - ? GetElementPtrInst::CreateInBounds( - Builder.getInt8Ty(), Src->getOperand(0), - Builder.getInt(OffsetOld), GEP.getName()) - : GetElementPtrInst::Create( - Builder.getInt8Ty(), Src->getOperand(0), - Builder.getInt(OffsetOld), GEP.getName()); + return replaceInstUsesWith( + GEP, Builder.CreateGEP( + Builder.getInt8Ty(), Src->getOperand(0), + Builder.getInt(OffsetOld), "", + isMergedGEPInBounds(*Src, *cast(&GEP)))); return nullptr; } @@ -2066,13 +2064,9 @@ Instruction *InstCombinerImpl::visitGEPOfGEP(GetElementPtrInst &GEP, IsInBounds &= Idx.isNonNegative() == ConstIndices[0].isNonNegative(); } - return IsInBounds - ? GetElementPtrInst::CreateInBounds(Src->getSourceElementType(), - Src->getOperand(0), Indices, - GEP.getName()) - : GetElementPtrInst::Create(Src->getSourceElementType(), - Src->getOperand(0), Indices, - GEP.getName()); + return replaceInstUsesWith( + GEP, Builder.CreateGEP(Src->getSourceElementType(), Src->getOperand(0), + Indices, "", IsInBounds)); } if (Src->getResultElementType() != GEP.getSourceElementType()) @@ -2126,13 +2120,10 @@ Instruction *InstCombinerImpl::visitGEPOfGEP(GetElementPtrInst &GEP, } if (!Indices.empty()) - return isMergedGEPInBounds(*Src, *cast(&GEP)) - ? GetElementPtrInst::CreateInBounds( - Src->getSourceElementType(), Src->getOperand(0), Indices, - GEP.getName()) - : GetElementPtrInst::Create(Src->getSourceElementType(), - Src->getOperand(0), Indices, - GEP.getName()); + return replaceInstUsesWith( + GEP, Builder.CreateGEP( + Src->getSourceElementType(), Src->getOperand(0), Indices, "", + isMergedGEPInBounds(*Src, *cast(&GEP)))); return nullptr; }