Changes in directory llvm/lib/VMCore:

Instructions.cpp updated: 1.84 -> 1.85
---
Log message:

add GetElementPtrInst::hasAllZeroIndices, a long-overdue helper method.
Writing it twice in the same day was too much for me.


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

 Instructions.cpp |   16 ++++++++++++++++
 1 files changed, 16 insertions(+)


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.84 
llvm/lib/VMCore/Instructions.cpp:1.85
--- llvm/lib/VMCore/Instructions.cpp:1.84       Wed Apr 11 08:04:48 2007
+++ llvm/lib/VMCore/Instructions.cpp    Fri Apr 13 19:12:57 2007
@@ -966,6 +966,22 @@
   return PTy->getElementType();
 }
 
+
+/// hasAllZeroIndices - Return true if all of the indices of this GEP are
+/// zeros.  If so, the result pointer and the first operand have the same
+/// value, just potentially different types.
+bool GetElementPtrInst::hasAllZeroIndices() const {
+  for (unsigned i = 1, e = getNumOperands(); i != e; ++i) {
+    if (ConstantInt *CI = dyn_cast<ConstantInt>(getOperand(i))) {
+      if (!CI->isZero()) return false;
+    } else {
+      return false;
+    }
+  }
+  return true;
+}
+
+
 
//===----------------------------------------------------------------------===//
 //                           ExtractElementInst Implementation
 
//===----------------------------------------------------------------------===//



_______________________________________________
llvm-commits mailing list
[EMAIL PROTECTED]
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to