[llvm] Preserve inbound of transformed GEPs (PR #86885)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 15:45:06 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff c7d947f5e6c966bdba4db26097c3b433fcbe7841 f6e17af5661003b97c2c2a5af3b8c1370e393261 -- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp llvm/lib/Transforms/Scalar/LoopFlatten.cpp llvm/lib/Transforms/Scalar/NaryReassociate.cpp llvm/lib/Transforms/Scalar/Scalarizer.cpp llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
index f1bdc20140..9316333aa2 100644
--- a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
@@ -808,8 +808,9 @@ static bool DoFlattenLoopPair(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI,
// we need to insert the new GEP where the old GEP was.
if (!DT->dominates(Base, &*Builder.GetInsertPoint()))
Builder.SetInsertPoint(cast<Instruction>(V));
- OuterValue = Builder.CreateGEP(GEP->getSourceElementType(), Base,
- OuterValue, "flatten." + V->getName(), GEP->isInBounds());
+ OuterValue =
+ Builder.CreateGEP(GEP->getSourceElementType(), Base, OuterValue,
+ "flatten." + V->getName(), GEP->isInBounds());
}
LLVM_DEBUG(dbgs() << "Replacing: "; V->dump(); dbgs() << "with: ";
diff --git a/llvm/lib/Transforms/Scalar/NaryReassociate.cpp b/llvm/lib/Transforms/Scalar/NaryReassociate.cpp
index 6ebe48813d..f6d3978326 100644
--- a/llvm/lib/Transforms/Scalar/NaryReassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/NaryReassociate.cpp
@@ -456,8 +456,8 @@ NaryReassociatePass::tryReassociateGEPAtIndex(GetElementPtrInst *GEP,
RHS = Builder.CreateMul(
RHS, ConstantInt::get(PtrIdxTy, IndexedSize / ElementSize));
}
- GetElementPtrInst *NewGEP = cast<GetElementPtrInst>(
- Builder.CreateGEP(GEP->getResultElementType(), Candidate, RHS, "", GEP->isInBounds()));
+ GetElementPtrInst *NewGEP = cast<GetElementPtrInst>(Builder.CreateGEP(
+ GEP->getResultElementType(), Candidate, RHS, "", GEP->isInBounds()));
NewGEP->takeName(GEP);
return NewGEP;
}
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index 5301bd8b0c..c92ea83a49 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -845,9 +845,10 @@ bool ScalarizerVisitor::visitGetElementPtrInst(GetElementPtrInst &GEPI) {
else
SplitOps[J] = ScatterOps[J][I];
}
- Res[I] = Builder.CreateGEP(GEPI.getSourceElementType(), SplitOps[0],
- ArrayRef(SplitOps).drop_front(),
- GEPI.getName() + ".i" + Twine(I), GEPI.isInBounds());
+ Res[I] =
+ Builder.CreateGEP(GEPI.getSourceElementType(), SplitOps[0],
+ ArrayRef(SplitOps).drop_front(),
+ GEPI.getName() + ".i" + Twine(I), GEPI.isInBounds());
}
gather(&GEPI, Res, *VS);
return true;
diff --git a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
index 145c50104a..789cf580e3 100644
--- a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
+++ b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
@@ -1020,9 +1020,11 @@ bool SeparateConstOffsetFromGEP::reorderGEP(GetElementPtrInst *GEP,
// For trivial GEP chains, we can swap the indicies.
auto NewSrc = Builder.CreateGEP(PtrGEPType, PtrGEP->getPointerOperand(),
- SmallVector<Value *, 4>(GEP->indices()), "", IsChainInBounds);
+ SmallVector<Value *, 4>(GEP->indices()), "",
+ IsChainInBounds);
auto NewGEP = Builder.CreateGEP(GEPType, NewSrc,
- SmallVector<Value *, 4>(PtrGEP->indices()), "", IsChainInBounds);
+ SmallVector<Value *, 4>(PtrGEP->indices()),
+ "", IsChainInBounds);
GEP->replaceAllUsesWith(NewGEP);
RecursivelyDeleteTriviallyDeadInstructions(GEP);
return true;
``````````
</details>
https://github.com/llvm/llvm-project/pull/86885
More information about the llvm-commits
mailing list