[llvm] 53ae96d - [BasicAA] Avoid duplicate query for GEPs with identical offsets (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 14 08:25:12 PST 2021
Author: Nikita Popov
Date: 2021-02-14T17:18:28+01:00
New Revision: 53ae96d4bb4976c458b5c50e00782980efba9ded
URL: https://github.com/llvm/llvm-project/commit/53ae96d4bb4976c458b5c50e00782980efba9ded
DIFF: https://github.com/llvm/llvm-project/commit/53ae96d4bb4976c458b5c50e00782980efba9ded.diff
LOG: [BasicAA] Avoid duplicate query for GEPs with identical offsets (NFCI)
For two GEPs with identical offsets, we currently first perform
a base address query without size information, and then if it is
MayAlias, perform another with size information. This is pointless,
as the latter query should produce strictly better results.
This was not quite true historically due to the way that NoAlias
assumptions were handled, but that issue has since been resolved.
Added:
Modified:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 8f07aa664392..b7af5110fb14 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1116,21 +1116,17 @@ AliasResult BasicAAResult::aliasGEP(
DecompGEP1.Offset -= DecompGEP2.Offset;
GetIndexDifference(DecompGEP1.VarIndices, DecompGEP2.VarIndices);
- // Do the base pointers alias?
- AliasResult BaseAlias = getBestAAResults().alias(
- MemoryLocation::getBeforeOrAfter(UnderlyingV1),
- MemoryLocation::getBeforeOrAfter(UnderlyingV2), AAQI);
-
// For GEPs with identical offsets, we can preserve the size and AAInfo
// when performing the alias check on the underlying objects.
- if (BaseAlias == MayAlias && DecompGEP1.Offset == 0 &&
- DecompGEP1.VarIndices.empty()) {
- AliasResult PreciseBaseAlias = getBestAAResults().alias(
+ if (DecompGEP1.Offset == 0 && DecompGEP1.VarIndices.empty())
+ return getBestAAResults().alias(
MemoryLocation(UnderlyingV1, V1Size, V1AAInfo),
MemoryLocation(UnderlyingV2, V2Size, V2AAInfo), AAQI);
- if (PreciseBaseAlias == NoAlias)
- return NoAlias;
- }
+
+ // Do the base pointers alias?
+ AliasResult BaseAlias = getBestAAResults().alias(
+ MemoryLocation::getBeforeOrAfter(UnderlyingV1),
+ MemoryLocation::getBeforeOrAfter(UnderlyingV2), AAQI);
// If we get a No or May, then return it immediately, no amount of analysis
// will improve this situation.
More information about the llvm-commits
mailing list