From 551d49b6ebdddedb3867ec4e23d8245243b8e168 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 4 Dec 2024 17:08:50 +0100 Subject: [PATCH] [LAA] Strip non-inbounds offset in getPointerDiff() (NFC) I believe that this code doesn't care whether the offsets are known to be inbounds a priori. For the same reason the change is not testable, as the SCEV based fallback code will look through non-inbounds offset anyway. So make it clear that there is no special inbounds requirement here. --- llvm/lib/Analysis/LoopAccessAnalysis.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 71582d5d86549..2c75d5625cb66 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -1566,10 +1566,10 @@ std::optional llvm::getPointersDiff(Type *ElemTyA, Value *PtrA, unsigned IdxWidth = DL.getIndexSizeInBits(ASA); APInt OffsetA(IdxWidth, 0), OffsetB(IdxWidth, 0); - const Value *PtrA1 = - PtrA->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetA); - const Value *PtrB1 = - PtrB->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetB); + const Value *PtrA1 = PtrA->stripAndAccumulateConstantOffsets( + DL, OffsetA, /*AllowNonInbounds=*/true); + const Value *PtrB1 = PtrB->stripAndAccumulateConstantOffsets( + DL, OffsetB, /*AllowNonInbounds=*/true); int Val; if (PtrA1 == PtrB1) {