From: Chris Lattner Date: Wed, 14 Feb 2007 07:18:16 +0000 (+0000) Subject: Refix CodeGen/Generic/switch-lower.ll. In contrast to my previous patch, X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=21840b1c5c8e0fcedf236f0c2b95e9e147859a8e;p=oota-llvm.git Refix CodeGen/Generic/switch-lower.ll. In contrast to my previous patch, this doesn't miscompile lots of programs :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34268 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index e72d88c7340..0192c287cd1 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -1205,8 +1205,8 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) { if ((TLI.isOperationLegal(ISD::BR_JT, MVT::Other) || TLI.isOperationLegal(ISD::BRIND, MVT::Other)) && Cases.size() > 5) { - uint64_t First =cast(Cases.front().first)->getZExtValue(); - uint64_t Last = cast(Cases.back().first)->getZExtValue(); + uint64_t First =cast(Cases.front().first)->getSExtValue(); + uint64_t Last = cast(Cases.back().first)->getSExtValue(); double Density = (double)Cases.size() / (double)((Last - First) + 1ULL); if (Density >= 0.3125) { @@ -1255,7 +1255,7 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) { std::vector DestBBs; uint64_t TEI = First; for (CaseItr ii = Cases.begin(), ee = Cases.end(); ii != ee; ++TEI) - if (cast(ii->first)->getZExtValue() == TEI) { + if (cast(ii->first)->getSExtValue() == TEI) { DestBBs.push_back(ii->second); ++ii; } else { @@ -1363,8 +1363,8 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) { // Create a CaseBlock record representing a conditional branch to // the LHS node if the value being switched on SV is less than C. // Otherwise, branch to LHS. - ISD::CondCode CC = ISD::SETLT; - SelectionDAGISel::CaseBlock CB(CC, SV, C, TrueBB, FalseBB, CR.CaseBB); + SelectionDAGISel::CaseBlock CB(ISD::SETLT, SV, C, TrueBB, FalseBB, + CR.CaseBB); if (CR.CaseBB == CurMBB) visitSwitchCase(CB);