[llvm-commits] [llvm] r157315 - /llvm/trunk/lib/Transforms/Utils/Local.cpp
Chandler Carruth
chandlerc at google.com
Wed May 23 01:32:26 PDT 2012
On Wed, May 23, 2012 at 1:18 AM, Stepan Dyatkovskiy <stpworld at narod.ru>wrote:
> 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.
>
Please be a bit more descriptive in your commit logs.
What changes? What specifically motivates them?
Also, why don't we have a test case for this? Is it caught by existing
tests with case ranges enabled in some form? How did you spot the bug?
Etc...
>
>
> 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;
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120523/e989d4a4/attachment.html>
More information about the llvm-commits
mailing list