From 1c8f4b8c34a75e184ec40251225c2699efecedac Mon Sep 17 00:00:00 2001 From: Stepan Dyatkovskiy Date: Mon, 21 May 2012 10:44:40 +0000 Subject: PR1255 (case ranges: work with ConstantRangesSet instead of ConstantInt) related changes for Execution and Verifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157183 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/Interpreter/Execution.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/ExecutionEngine') diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index af47be9c5b..298ce2c2b9 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -651,10 +651,16 @@ void Interpreter::visitSwitchInst(SwitchInst &I) { // Check to see if any of the cases match... BasicBlock *Dest = 0; for (SwitchInst::CaseIt i = I.case_begin(), e = I.case_end(); i != e; ++i) { - GenericValue CaseVal = getOperandValue(i.getCaseValue(), SF); - if (executeICMP_EQ(CondVal, CaseVal, ElTy).IntVal != 0) { - Dest = cast(i.getCaseSuccessor()); - break; + ConstantRangesSet Case = i.getCaseValueEx(); + for (unsigned n = 0, en = Case.getNumItems(); n != en; ++n) { + ConstantRangesSet::Range r = Case.getItem(n); + GenericValue Low = getOperandValue(r.Low, SF); + GenericValue High = getOperandValue(r.High, SF); + if (executeICMP_ULE(Low, CondVal, ElTy).IntVal != 0 && + executeICMP_ULE(CondVal, High, ElTy).IntVal != 0) { + Dest = cast(i.getCaseSuccessor()); + break; + } } } if (!Dest) Dest = I.getDefaultDest(); // No cases matched: use default -- cgit v1.2.3