[llvm-commits] CVS: llvm/lib/Transforms/Scalar/SCCP.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Mar 11 23:53:08 PST 2004
Changes in directory llvm/lib/Transforms/Scalar:
SCCP.cpp updated: 1.90 -> 1.91
---
Log message:
Add sccp support for select instructions
---
Diffs of the changes: (+23 -0)
Index: llvm/lib/Transforms/Scalar/SCCP.cpp
diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.90 llvm/lib/Transforms/Scalar/SCCP.cpp:1.91
--- llvm/lib/Transforms/Scalar/SCCP.cpp:1.90 Sun Mar 7 16:16:24 2004
+++ llvm/lib/Transforms/Scalar/SCCP.cpp Thu Mar 11 23:52:44 2004
@@ -212,6 +212,7 @@
void visitTerminatorInst(TerminatorInst &TI);
void visitCastInst(CastInst &I);
+ void visitSelectInst(SelectInst &I);
void visitBinaryOperator(Instruction &I);
void visitShiftInst(ShiftInst &I) { visitBinaryOperator(I); }
@@ -563,6 +564,28 @@
markOverdefined(&I);
else if (VState.isConstant()) // Propagate constant value
markConstant(&I, ConstantExpr::getCast(VState.getConstant(), I.getType()));
+}
+
+void SCCP::visitSelectInst(SelectInst &I) {
+ InstVal &CondValue = getValueState(I.getCondition());
+ if (CondValue.isOverdefined())
+ markOverdefined(&I);
+ else if (CondValue.isConstant()) {
+ if (CondValue.getConstant() == ConstantBool::True) {
+ InstVal &Val = getValueState(I.getTrueValue());
+ if (Val.isOverdefined())
+ markOverdefined(&I);
+ else if (Val.isConstant())
+ markConstant(&I, Val.getConstant());
+ } else if (CondValue.getConstant() == ConstantBool::False) {
+ InstVal &Val = getValueState(I.getFalseValue());
+ if (Val.isOverdefined())
+ markOverdefined(&I);
+ else if (Val.isConstant())
+ markConstant(&I, Val.getConstant());
+ } else
+ markOverdefined(&I);
+ }
}
// Handle BinaryOperators and Shift Instructions...
More information about the llvm-commits
mailing list