[PATCH] Expand SimplifyCFG to convert certain simple switches to selects
Marcello Maggioni
hayarms at gmail.com
Sat Jun 21 07:21:28 PDT 2014
================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:3902
@@ +3901,3 @@
+ // Selects choose between two values only.
+ if (UniqueResults.size() != 2)
+ return false;
----------------
Marcello Maggioni wrote:
> Philip Reames wrote:
> > Since you're handling defaults, wouldn't it also make sense to handle one unique result and a default? i.e.
> > switch(i) {
> > case 4,5,6: return 5;
> > default: return 0;
> > }
> This is a good idea. I need to check if that is profitable in performance though (needs two comparisons to check if the value falls in the range). If it seems profitable I'll add it.
I actually checked and seems like this specific case is already handled by TurnSwitchRangeIntoICmp()
http://reviews.llvm.org/D4219
More information about the llvm-commits
mailing list