[llvm] 53280db - [InstCombine] Use CreateGEP() API (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 5 06:02:54 PDT 2023
Author: Nikita Popov
Date: 2023-04-05T15:02:45+02:00
New Revision: 53280dba83afc6a23a808b4429ed1e026664bfba
URL: https://github.com/llvm/llvm-project/commit/53280dba83afc6a23a808b4429ed1e026664bfba
DIFF: https://github.com/llvm/llvm-project/commit/53280dba83afc6a23a808b4429ed1e026664bfba.diff
LOG: [InstCombine] Use CreateGEP() API (NFC)
Use the IRBuilder API that accepts inbounds as a boolean parameter,
rather than using a ternary.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 7cae08df1171a..116e6b23a8a4d 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<GEPOperator>(&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<GEPOperator>(&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<GEPOperator>(&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<GEPOperator>(&GEP))));
return nullptr;
}
More information about the llvm-commits
mailing list