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

Chris Lattner lattner at cs.uiuc.edu
Tue Mar 30 20:57:01 PST 2004


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.85 -> 1.86

---
Log message:

Add support for constant expr casts


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

Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.85 llvm/lib/VMCore/Constants.cpp:1.86
--- llvm/lib/VMCore/Constants.cpp:1.85	Tue Mar 30 16:51:03 2004
+++ llvm/lib/VMCore/Constants.cpp	Tue Mar 30 20:56:11 2004
@@ -571,6 +571,14 @@
   } else if (getOpcode() == Instruction::Cast) {
     assert(getOperand(0) == From && "Cast only has one use!");
     Replacement = ConstantExpr::getCast(To, getType());
+  } else if (getOpcode() == Instruction::Select) {
+    Constant *C1 = getOperand(0);
+    Constant *C2 = getOperand(1);
+    Constant *C3 = getOperand(2);
+    if (C1 == From) C1 = To;
+    if (C2 == From) C2 = To;
+    if (C3 == From) C3 = To;
+    Replacement = ConstantExpr::getSelect(C1, C2, C3);
   } else if (getNumOperands() == 2) {
     Constant *C1 = getOperand(0);
     Constant *C2 = getOperand(1);





More information about the llvm-commits mailing list