[llvm] 0b72444 - [BasicAA] Remove unnecessary size limitation

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 14 07:51:46 PST 2020


Author: Nikita Popov
Date: 2020-11-14T16:51:31+01:00
New Revision: 0b72444211e4d2016cbb7628ab5fb8272ded43a2

URL: https://github.com/llvm/llvm-project/commit/0b72444211e4d2016cbb7628ab5fb8272ded43a2
DIFF: https://github.com/llvm/llvm-project/commit/0b72444211e4d2016cbb7628ab5fb8272ded43a2.diff

LOG: [BasicAA] Remove unnecessary size limitation

We're dropping a common offset from both GEPs here. It's not
necessary for the access sizes to be the same as well.

Added: 
    

Modified: 
    llvm/lib/Analysis/BasicAliasAnalysis.cpp
    llvm/test/Analysis/BasicAA/noalias-geps.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index aa83fed6d3ac..72f74ab18a59 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1293,10 +1293,9 @@ AliasResult BasicAAResult::aliasGEP(
         aliasCheck(UnderlyingV1, LocationSize::unknown(), AAMDNodes(),
                    UnderlyingV2, LocationSize::unknown(), AAMDNodes(), AAQI);
 
-    // For GEPs with identical sizes and offsets, we can preserve the size
-    // and AAInfo when performing the alias check on the underlying objects.
-    if (BaseAlias == MayAlias && V1Size == V2Size &&
-        GEP1BaseOffset == GEP2BaseOffset &&
+    // For GEPs with identical offsets, we can preserve the size and AAInfo
+    // when performing the alias check on the underlying objects.
+    if (BaseAlias == MayAlias && GEP1BaseOffset == GEP2BaseOffset &&
         DecompGEP1.VarIndices == DecompGEP2.VarIndices) {
       AliasResult PreciseBaseAlias = aliasCheck(
           UnderlyingV1, V1Size, V1AAInfo, UnderlyingV2, V2Size, V2AAInfo, AAQI);

diff  --git a/llvm/test/Analysis/BasicAA/noalias-geps.ll b/llvm/test/Analysis/BasicAA/noalias-geps.ll
index 545df2154a8f..9a4a35dd894b 100644
--- a/llvm/test/Analysis/BasicAA/noalias-geps.ll
+++ b/llvm/test/Analysis/BasicAA/noalias-geps.ll
@@ -25,6 +25,9 @@ bb3:
 ; CHECK: NoAlias: i32* %f1, i32* %g1
   %f1 = getelementptr i32, i32* %ptr_phi , i32 1
   %g1 = getelementptr i32, i32* %ptr_phi2 , i32 1
+; This should also work if the access size is not the same.
+; CHECK: NoAlias: i16* %h1, i32* %f1
+  %h1 = bitcast i32* %g1 to i16*
 
 ret i32 0
 }


        


More information about the llvm-commits mailing list