[PATCH] Improve BasicAA Pass Using zext Information

hfinkel at anl.gov hfinkel at anl.gov
Sun Sep 28 15:10:25 PDT 2014


================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:258
@@ +257,3 @@
+
+    // we have to sign-extend even if Extension == EK_ZeroExt as we can't
+    // decompose a sign extension (i.e. zext(x - 1) != zext(x) - zext(-1))
----------------
Start sentence with a capital w (similar with other comments below).

================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:1067
@@ +1066,3 @@
+      // regardless of whether the value is signed or unsigned
+      AllPositive &= GEP1VariableIndices[i].Extension == EK_ZeroExt;
+    }
----------------
To note a possible follow-up, we might also be able to determine this by using ComputeSignBit from ValueTracking.h

================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:1082
@@ +1081,3 @@
+    // don't alias if V2Size can fit in the gap between V2 and GEP1BasePtr.
+    if(AllPositive && GEP1BaseOffset > 0 && V2Size <= (uint64_t) GEP1BaseOffset)
+      return NoAlias;
----------------
Add a space in between the if and the (

================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:1229
@@ +1228,3 @@
+  // mean these Values no longer alias, or now alias when we reach PN, so
+  // we'll just return MayAlias ("don't know").
+  DominatorTreeWrapperPass *DTWP =
----------------
I think you can remove the ("don't know") next to MayAlias.

More importantly, please also explain in the comment what the loop below actually checks and why that ensures the condition you explain above.

Also, an example of this would be helpful.

================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:1237
@@ +1236,3 @@
+    const Instruction *Inst = dyn_cast<Instruction>(V1Srcs[i]);
+    if(Inst && isPotentiallyReachable(PN, Inst, DT, LI))
+      return MayAlias;
----------------
Space after the if.

http://reviews.llvm.org/D5514






More information about the llvm-commits mailing list