From 858c3299c15ef32d55f111c4b25b0dde1f16281f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 10 May 2008 23:56:54 +0000 Subject: [PATCH] Simplify code by using SwitchInst::findCaseValue instead of reimplementing it. llvm-svn: 50957 --- lib/Transforms/Scalar/SCCP.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index be071f8b1fa..6e76f4c8cc7 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -448,20 +448,8 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI, (SCValue.isConstant() && !isa(SCValue.getConstant()))) { // All destinations are executable! Succs.assign(TI.getNumSuccessors(), true); - } else if (SCValue.isConstant()) { - Constant *CPV = SCValue.getConstant(); - // Make sure to skip the "default value" which isn't a value - for (unsigned i = 1, E = SI->getNumSuccessors(); i != E; ++i) { - if (SI->getSuccessorValue(i) == CPV) {// Found the right branch... - Succs[i] = true; - return; - } - } - - // Constant value not equal to any of the branches... must execute - // default branch then... - Succs[0] = true; - } + } else if (SCValue.isConstant()) + Succs[SI->findCaseValue(cast(SCValue.getConstant()))] = true; } else { assert(0 && "SCCP: Don't know how to handle this terminator!"); }