[llvm] e6d22d0 - [BasicAA] Use separate scale variable for GCD.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 30 12:06:24 PDT 2021
Author: Florian Hahn
Date: 2021-06-30T20:04:39+01:00
New Revision: e6d22d0174e09fa01342d9ed1dca47bc1eb58303
URL: https://github.com/llvm/llvm-project/commit/e6d22d0174e09fa01342d9ed1dca47bc1eb58303
DIFF: https://github.com/llvm/llvm-project/commit/e6d22d0174e09fa01342d9ed1dca47bc1eb58303.diff
LOG: [BasicAA] Use separate scale variable for GCD.
Use separate variable for adjusted scale used for GCD computations. This
fixes an issue where we incorrectly determined that all indices are
non-negative and returned noalias because of that.
Follow up to 91fa3565da16.
Added:
Modified:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/gep-modulo.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index da489b8d457fb..d79df622ee501 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1148,14 +1148,15 @@ AliasResult BasicAAResult::aliasGEP(
bool AllNonPositive = DecompGEP1.Offset.isNonPositive();
for (unsigned i = 0, e = DecompGEP1.VarIndices.size(); i != e; ++i) {
APInt Scale = DecompGEP1.VarIndices[i].Scale;
+ APInt ScaleForGDC = DecompGEP1.VarIndices[i].Scale;
if (!DecompGEP1.VarIndices[i].IsNSW)
- Scale = APInt::getOneBitSet(Scale.getBitWidth(),
- Scale.countTrailingZeros());
+ ScaleForGDC = APInt::getOneBitSet(Scale.getBitWidth(),
+ Scale.countTrailingZeros());
if (i == 0)
- GCD = Scale.abs();
+ GCD = ScaleForGDC.abs();
else
- GCD = APIntOps::GreatestCommonDivisor(GCD, Scale.abs());
+ GCD = APIntOps::GreatestCommonDivisor(GCD, ScaleForGDC.abs());
if (AllNonNegative || AllNonPositive) {
// If the Value could change between cycles, then any reasoning about
diff --git a/llvm/test/Analysis/BasicAA/gep-modulo.ll b/llvm/test/Analysis/BasicAA/gep-modulo.ll
index cf75ba5101b1f..22b4310d088e7 100644
--- a/llvm/test/Analysis/BasicAA/gep-modulo.ll
+++ b/llvm/test/Analysis/BasicAA/gep-modulo.ll
@@ -282,8 +282,8 @@ define void @may_overflow_mul_scale_neg([200 x [ 6 x i8]]* %ptr, i64 %idx.1,i64
; CHECK-NEXT: PartialAlias (off 6): [200 x [6 x i8]]* %ptr, i8* %gep.1
; CHECK-NEXT: NoAlias: i8* %bc, i8* %gep.1
; CHECK-NEXT: MayAlias: [200 x [6 x i8]]* %ptr, i8* %gep.idx
-; CHECK-NEXT: NoAlias: i8* %bc, i8* %gep.idx
-; CHECK-NEXT: NoAlias: i8* %gep.1, i8* %gep.idx
+; CHECK-NEXT: MayAlias: i8* %bc, i8* %gep.idx
+; CHECK-NEXT: MayAlias: i8* %gep.1, i8* %gep.idx
;
%idx.1.pos = icmp sge i64 %idx.1, 0
call void @llvm.assume(i1 %idx.1.pos)
More information about the llvm-commits
mailing list