[PATCH] [BasicAA] Fix zext & sext handling

hfinkel at anl.gov hfinkel at anl.gov
Fri Jan 9 06:15:52 PST 2015


================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:219
@@ -212,3 +218,3 @@
     // and remove the variable.
-    Offset += Const->getValue();
+    Offset += Const->getValue().zextOrSelf(Offset.getBitWidth());
     assert(Scale == 0 && "Constant values don't have a scale");
----------------
Why do we always zero-extend here? Why not sign extend? There should at least be a comment explaining this.

================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:229
@@ +228,3 @@
+      // that the BOp operands. We'll always zext it here as we'll process sign
+      // extensions in the caller.
+      APInt RHS = RHSC->getValue().zextOrSelf(Offset.getBitWidth());
----------------
You might want to add "see below" or some other hint to where this happens.

================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:294
@@ +293,3 @@
+
+    // this check encodes the rule sext(zext(%x, a), b) == zext(%x, a + b)
+    if (isa<SExtInst>(V) && ZExtBits == 0) {
----------------
this -> This

================
Comment at: lib/Analysis/BasicAliasAnalysis.cpp:297
@@ +296,3 @@
+      if (NSW) {
+        // we haven't sign-wrapped, so it's valid to decompose sext(%x + c)
+        // into sext(%x) + sext(c). We'll sext the Offset ourselves:
----------------
we -> We

http://reviews.llvm.org/D6682

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list