[llvm-branch-commits] [llvm] [InstCombine] Improve inbounds preservation for ADD+GEP -> GEP+GEP (PR #135155)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Apr 10 06:03:28 PDT 2025
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 HEAD~1 HEAD --extensions cpp -- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index b5e085be9..09b6f4880 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3091,8 +3091,7 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
DL.getIndexSizeInBits(PtrOp->getType()->getPointerAddressSpace());
APInt BasePtrOffset(IdxWidth, 0);
Value *UnderlyingPtrOp =
- PtrOp->stripAndAccumulateInBoundsConstantOffsets(DL,
- BasePtrOffset);
+ PtrOp->stripAndAccumulateInBoundsConstantOffsets(DL, BasePtrOffset);
bool CanBeNull, CanBeFreed;
uint64_t DerefBytes = UnderlyingPtrOp->getPointerDereferenceableBytes(
DL, CanBeNull, CanBeFreed);
@@ -3120,7 +3119,8 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// These rewrites is trying to preserve inbounds/nuw attributes. So we want to
// do this after having tried to derive "nuw" above.
if (GEP.getNumIndices() == 1) {
- auto GetPreservedNoWrapFlags = [&](bool AddIsNUW, Value *Idx1, Value *Idx2) {
+ auto GetPreservedNoWrapFlags = [&](bool AddIsNUW, Value *Idx1,
+ Value *Idx2) {
// Preserve "inbounds nuw" if the original gep is "inbounds nuw", and the
// add is "nuw". Preserve "nuw" if the original gep is "nuw", and the add
// is "nuw".
@@ -3160,8 +3160,8 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// as:
// %newptr = getelementptr i32, ptr %ptr, i32 %idx1
// %newgep = getelementptr i32, ptr %newptr, i32 idx2
- bool NUW = match(GEP.getOperand(1), m_NNegZExt(m_NUWAddLike(m_Value(),
- m_Value())));
+ bool NUW = match(GEP.getOperand(1),
+ m_NNegZExt(m_NUWAddLike(m_Value(), m_Value())));
GEPNoWrapFlags NWFlags = GetPreservedNoWrapFlags(NUW, Idx1, C);
auto *NewPtr = Builder.CreateGEP(
GEP.getSourceElementType(), GEP.getPointerOperand(),
``````````
</details>
https://github.com/llvm/llvm-project/pull/135155
More information about the llvm-branch-commits
mailing list