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

Chris Lattner lattner at cs.uiuc.edu
Thu Mar 11 23:54:09 PST 2004


Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.54 -> 1.55

---
Log message:

Teach the constant folder how to do select instructions


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

Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.54 llvm/lib/VMCore/ConstantFolding.cpp:1.55
--- llvm/lib/VMCore/ConstantFolding.cpp:1.54	Mon Mar  8 00:17:35 2004
+++ llvm/lib/VMCore/ConstantFolding.cpp	Thu Mar 11 23:53:32 2004
@@ -582,6 +582,17 @@
   }
 }
 
+Constant *llvm::ConstantFoldSelectInstruction(const Constant *Cond,
+                                              const Constant *V1,
+                                              const Constant *V2) {
+  if (Cond == ConstantBool::True)
+    return const_cast<Constant*>(V1);
+  else if (Cond == ConstantBool::False)
+    return const_cast<Constant*>(V2);
+  return 0;
+}
+
+
 /// IdxCompare - Compare the two constants as though they were getelementptr
 /// indices.  This allows coersion of the types to be the same thing.
 ///





More information about the llvm-commits mailing list