[llvm-commits] [llvm] r163302 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/switch_create.ll test/Transforms/SimplifyCFG/switch_to_lookup_table.ll

Chandler Carruth chandlerc at google.com
Mon Sep 10 01:36:19 PDT 2012


On Mon, Sep 10, 2012 at 1:18 AM, Duncan Sands <baldrick at free.fr> wrote:

> Hi Hans,
>
>
>  Just for perspective I had one other idea of how this type of transform
>>> might be implemented. I was talked out of it by someone, although I don't
>>> remember who, but I think it's still at least useful to think about.
>>>
>>> My idea had been to extend the IR to directly represent the concept of
>>> this
>>> operation. Currently, we have a 'br' instruction to represent binary
>>> control
>>> flow selection, and we have a 'switch' instruction to represent N-way
>>> control flow selection. We also have 'select' to represent binary value
>>> selection, but no instruction to represent N-way value selection. I
>>> suggested adding a new instruction 'selectswitch' (or some better name)
>>> to
>>> support selecting over N values based on an integer much the way switch
>>> works.
>>>
>>
>> Would it be completely crazy to just extend the current select
>> instruction? It already does N-way value selection, it's just that N
>> is always 2.
>>
>
> alternatively, how about removing the select instruction from the IR
> altogether?  Maybe "select" really belongs in codegen only...
>

I think it is extremely useful in the IR.

Without this type of formation, the number of basic blocks and control flow
edges would be much higher. A lot of things that are currently one CFG edge
of separation would become two or three. This would significantly
complicate and slow down many optimization passes. Because we have an
efficient model for representing select events in the SSA IR, I think it is
very useful to have it in order to simplify the CFGs of the code and
expedite analyses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120910/fd7c04db/attachment.html>


More information about the llvm-commits mailing list