[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 14 11:10:00 PST 2003


Changes in directory llvm/lib/Analysis/DataStructure:

Local.cpp updated: 1.72 -> 1.73

---
Log message:

Implement a small optimization to handling of GEP's that are equivalent to casts.
This results in substantially reduced collapsing for some testcases


---
Diffs of the changes:  (+18 -0)

Index: llvm/lib/Analysis/DataStructure/Local.cpp
diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.72 llvm/lib/Analysis/DataStructure/Local.cpp:1.73
--- llvm/lib/Analysis/DataStructure/Local.cpp:1.72	Wed Nov 12 21:10:49 2003
+++ llvm/lib/Analysis/DataStructure/Local.cpp	Fri Nov 14 11:09:46 2003
@@ -308,6 +308,24 @@
   DSNodeHandle Value = getValueDest(*GEP.getOperand(0));
   if (Value.getNode() == 0) return;
 
+  // As a special case, if all of the index operands of GEP are constant zeros,
+  // handle this just like we handle casts (ie, don't do much).
+  bool AllZeros = true;
+  for (unsigned i = 1, e = GEP.getNumOperands(); i != e; ++i)
+    if (GEP.getOperand(i) !=
+           Constant::getNullValue(GEP.getOperand(i)->getType())) {
+      AllZeros = false;
+      break;
+    }
+
+  // If all of the indices are zero, the result points to the operand without
+  // applying the type.
+  if (AllZeros) {
+    setDestTo(GEP, Value);
+    return;
+  }
+
+
   const PointerType *PTy = cast<PointerType>(GEP.getOperand(0)->getType());
   const Type *CurTy = PTy->getElementType();
 





More information about the llvm-commits mailing list