[llvm-commits] [llvm] r157315 - /llvm/trunk/lib/Transforms/Utils/Local.cpp
Stepan Dyatkovskiy
stpworld at narod.ru
Wed May 23 01:18:26 PDT 2012
Author: dyatkovskiy
Date: Wed May 23 03:18:26 2012
New Revision: 157315
URL: http://llvm.org/viewvc/llvm-project?rev=157315&view=rev
Log:
PR1255(case ranges) related changes in Local Transformations.
Modified:
llvm/trunk/lib/Transforms/Utils/Local.cpp
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=157315&r1=157314&r2=157315&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed May 23 03:18:26 2012
@@ -169,16 +169,20 @@
// Otherwise, we can fold this switch into a conditional branch
// instruction if it has only one non-default destination.
SwitchInst::CaseIt FirstCase = SI->case_begin();
- Value *Cond = Builder.CreateICmpEQ(SI->getCondition(),
- FirstCase.getCaseValue(), "cond");
-
- // Insert the new branch.
- Builder.CreateCondBr(Cond, FirstCase.getCaseSuccessor(),
- SI->getDefaultDest());
-
- // Delete the old switch.
- SI->eraseFromParent();
- return true;
+ ConstantRangesSet CRS = FirstCase.getCaseValueEx();
+ if (CRS.getNumItems() == 1 && CRS.isSingleNumber(0)) {
+ Value *Cond = Builder.CreateICmpEQ(SI->getCondition(),
+ CRS.getItem(0).Low, "cond");
+
+ // Insert the new branch.
+ Builder.CreateCondBr(Cond, FirstCase.getCaseSuccessor(),
+ SI->getDefaultDest());
+
+ // Delete the old switch.
+ SI->eraseFromParent();
+ return true;
+
+ }
}
return false;
}
More information about the llvm-commits
mailing list