[PATCH] Fix another constant folding address space place I missed.

Quentin Colombet qcolombet at apple.com
Wed Oct 30 13:08:46 PDT 2013


  Hi Matt,

  This LGTM with one stylistic change.

  Thanks,
  -Quentin


================
Comment at: lib/Analysis/ConstantFolding.cpp:242
@@ -240,2 +241,3 @@
   // i32* getelementptr ([5 x i32]* @a, i32 0, i32 5)
   if (GEPOperator *GEP = dyn_cast<GEPOperator>(CE)) {
+    unsigned BitWidth = TD.getPointerTypeSizeInBits(GEP->getType());
----------------
Now that the ‘if’ has a bigger block, I would invert the condition to remove the indentation.
I.e.,
GEPOperator *GEP = dyn_cast<GEPOperator>(CE);
if (!GEP) return false;

================
Comment at: lib/Analysis/ConstantFolding.cpp:251
@@ -246,2 +250,3 @@
     // Otherwise, add any offset that our operands provide.
-    return GEP->accumulateConstantOffset(TD, Offset);
+    if (GEP->accumulateConstantOffset(TD, TmpOffset)) {
+      Offset = TmpOffset;
----------------
Same here, invert the condition and return false.

================
Comment at: lib/Analysis/ConstantFolding.cpp:257
@@ -249,3 +256,3 @@
 
   return false;
 }
----------------
Update Offset here and return true.


http://llvm-reviews.chandlerc.com/D1664



More information about the llvm-commits mailing list