[all-commits] [llvm/llvm-project] cd3c22: [BasicAA] Generalize base offset modulus handling
Nikita Popov via All-commits
all-commits at lists.llvm.org
Wed Nov 18 12:49:13 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: cd3c22c47e4bef347599e137ee6b1c3c510d7902
https://github.com/llvm/llvm-project/commit/cd3c22c47e4bef347599e137ee6b1c3c510d7902
Author: Nikita Popov <nikita.ppv at gmail.com>
Date: 2020-11-18 (Wed, 18 Nov 2020)
Changed paths:
M llvm/lib/Analysis/BasicAliasAnalysis.cpp
M llvm/test/Analysis/BasicAA/struct-geps.ll
Log Message:
-----------
[BasicAA] Generalize base offset modulus handling
The GEP aliasing implementation currently has two pieces of code
that solve two different subsets of the same basic problem: If you
have GEPs with offsets 4*x + 0 and 4*y + 1 (assuming access size 1),
then they do not alias regardless of whether x and y are the same.
One implementation is in aliasSameBasePointerGEPs(), which looks at
this in a limited structural way. It requires both GEP base pointers
to be exactly the same, then (optionally) a number of equal indexes,
then an unknown index, then a non-equal index into a struct. This
set of limitations works, but it's overly restrictive and hides the
core property we're trying to exploit.
The second implementation is part of aliasGEP() itself and tries to
find a common modulus in the scales, so it can then check that the
constant offset doesn't overlap under modular arithmetic. The second
implementation has the right idea of what the general problem is,
but effectively only considers power of two factors in the scales
(while aliasSameBasePointerGEPs also works with non-pow2 struct sizes.)
What this patch does is to adjust the aliasGEP() implementation to
instead find the largest common factor in all the scales (i.e. the GCD)
and use that as the modulus.
Differential Revision: https://reviews.llvm.org/D91027
More information about the All-commits
mailing list