[PATCH] D19935: [BasicAA] Compare GEP indices based on value

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 13:34:53 PDT 2016


vsk updated this revision to Diff 56454.
vsk added a comment.

- Updated with Ahmed's suggested test case.


http://reviews.llvm.org/D19935

Files:
  lib/Analysis/BasicAliasAnalysis.cpp
  test/Analysis/BasicAA/struct-geps.ll

Index: test/Analysis/BasicAA/struct-geps.ll
===================================================================
--- test/Analysis/BasicAA/struct-geps.ll
+++ test/Analysis/BasicAA/struct-geps.ll
@@ -162,3 +162,12 @@
   %y = getelementptr %struct2, %struct2* %st, i32 0, i32 0, i32 1, i32 1
   ret void
 }
+
+; PR27418 - Treat GEP indices with the same value but different types the same
+; CHECK-LABEL: test_different_index_types
+; CHECK: MustAlias: i16* %tmp1, i16* %tmp2
+define void @test_different_index_types([2 x i16]* %arr) {
+  %tmp1 = getelementptr [2 x i16], [2 x i16]* %arr, i16 0, i32 1
+  %tmp2 = getelementptr [2 x i16], [2 x i16]* %arr, i16 0, i16 1
+  ret void
+}
Index: lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- lib/Analysis/BasicAliasAnalysis.cpp
+++ lib/Analysis/BasicAliasAnalysis.cpp
@@ -819,7 +819,7 @@
 
   // If the last (struct) indices are constants and are equal, the other indices
   // might be also be dynamically equal, so the GEPs can alias.
-  if (C1 && C2 && C1 == C2)
+  if (C1 && C2 && C1->getSExtValue() == C2->getSExtValue())
     return MayAlias;
 
   // Find the last-indexed type of the GEP, i.e., the type you'd get if


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19935.56454.patch
Type: text/x-patch
Size: 1227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160506/1adbf7ad/attachment.bin>


More information about the llvm-commits mailing list