Skip to content

[BasicAA] Don't use MinAbsVarIndex = 1. #72993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions llvm/lib/Analysis/BasicAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,9 +1230,6 @@ AliasResult BasicAAResult::aliasGEP(
const VariableGEPIndex &Var = DecompGEP1.VarIndices[0];
if (Var.Val.TruncBits == 0 &&
isKnownNonZero(Var.Val.V, DL, 0, &AC, Var.CxtI, DT)) {
// If V != 0, then abs(VarIndex) > 0.
MinAbsVarIndex = APInt(Var.Scale.getBitWidth(), 1);

// Check if abs(V*Scale) >= abs(Scale) holds in the presence of
// potentially wrapping math.
auto MultiplyByScaleNoWrap = [](const VariableGEPIndex &Var) {
Expand Down
5 changes: 2 additions & 3 deletions llvm/test/Analysis/BasicAA/gep-modulo.ll
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ define i8 @mul_may_overflow_var_nonzero_minabsvarindex_one_index(ptr %arr, i8 %x
; CHECK-NEXT: PartialAlias (off 917): [2000 x i8]* %arr, i8* %gep.917
; CHECK-NEXT: MayAlias: i8* %gep.917, i8* %gep.idx
; CHECK-NEXT: MustAlias: [2000 x i8]* %arr, i8* %gep.0
; CHECK-NEXT: NoAlias: i8* %gep.0, i8* %gep.idx
; CHECK-NEXT: MayAlias: i8* %gep.0, i8* %gep.idx
; CHECK-NEXT: NoAlias: i8* %gep.0, i8* %gep.917
;
load [2000 x i8], ptr %arr
Expand Down Expand Up @@ -362,10 +362,9 @@ define i8 @mul_nsw_var_nonzero_minabsvarindex_one_index(ptr %arr, i8 %x, i64 %v)
ret i8 %l
}

; FIXME: %gep and %p can alias.
define i8 @test_pr72831_may_wrap(i64 %off) {
; CHECK-LABEL: Function: test_pr72831_may_wrap: 2 pointers, 0 call sites
; CHECK-NEXT: NoAlias: i8* %gep, i8* %p
; CHECK-NEXT: MayAlias: i8* %gep, i8* %p
entry:
%p = alloca [2 x i8], align 1
%ext = zext i1 false to i64
Expand Down