summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-12 05:52:44 +0000
committerChris Lattner <sabre@nondot.org>2004-03-12 05:52:44 +0000
commit59db22dcd4f44f4dccbe408e8e127298ecc696e0 (patch)
treed641b9e8bafb05212a29e5625d13f6603020455a /llvm/lib/Transforms
parentb909e8b0d4313f11cee79c3fb35110bc24f99fc2 (diff)
downloadbcm5719-llvm-59db22dcd4f44f4dccbe408e8e127298ecc696e0.tar.gz
bcm5719-llvm-59db22dcd4f44f4dccbe408e8e127298ecc696e0.zip
Add sccp support for select instructions
llvm-svn: 12318
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/SCCP.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 56cb2cc7701..26c246df000 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -212,6 +212,7 @@ private:
void visitTerminatorInst(TerminatorInst &TI);
void visitCastInst(CastInst &I);
+ void visitSelectInst(SelectInst &I);
void visitBinaryOperator(Instruction &I);
void visitShiftInst(ShiftInst &I) { visitBinaryOperator(I); }
@@ -565,6 +566,28 @@ void SCCP::visitCastInst(CastInst &I) {
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...
void SCCP::visitBinaryOperator(Instruction &I) {
InstVal &IV = ValueState[&I];
OpenPOWER on IntegriCloud