[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

Jim Laskey jlaskey at apple.com
Fri Jan 12 14:39:31 PST 2007



Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.198 -> 1.199
---
Log message:

Allow isAllOnesValue testing on packed constants

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

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


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.198 llvm/lib/VMCore/Constants.cpp:1.199
--- llvm/lib/VMCore/Constants.cpp:1.198	Fri Jan 12 01:05:14 2007
+++ llvm/lib/VMCore/Constants.cpp	Fri Jan 12 16:39:14 2007
@@ -1166,6 +1166,22 @@
   destroyConstantImpl();
 }
 
+/// This function will return true iff every element in this packed constant
+/// is set to all ones.
+/// @returns true iff this constant's emements are all set to all ones.
+/// @brief Determine if the value is all ones.
+bool ConstantPacked::isAllOnesValue() const {
+  // Check out first element.
+  const Constant *Elt = getOperand(0);
+  const ConstantInt *CI = dyn_cast<ConstantInt>(Elt);
+  if (!CI || !CI->isAllOnesValue()) return false;
+  // Then make sure all remaining elements point to the same value.
+  for (unsigned I = 1, E = getNumOperands(); I < E; ++I) {
+    if (getOperand(I) != Elt) return false;
+  }
+  return true;
+}
+
 //---- ConstantPointerNull::get() implementation...
 //
 






More information about the llvm-commits mailing list