On Tue, Aug 6, 2013 at 4:14 AM, Christoph Bumiller
<e0425...@student.tuwien.ac.at> wrote:
> On 06.08.2013 03:28, Kenneth Graunke wrote:
>> Many GLSL shaders contain code of the form:
>>
>>    x = condition ? foo : bar
>>
>> The compiler emits an ir_if tree for this, since each subexpression
>> might be a complex tree that could have side-effects and short-circuit
>> logic operations.
>>
>> However, the common case is to simply pick one of two constants or
>> variable's values---which is exactly what SEL is for.  Replacing IF/ELSE
>> with SEL also simplifies the control flow graph, making optimization
>> passes which work on basic blocks more effective.
>>
>
> Don't you think something like that should be implemented in common code
> so that all drivers can profit ?

We would love that. As part of an work in progress, I'm adding
conditional-select to the GLSL IR. We planned a few months ago to do
this as a step toward SSA at the IR level, but have only laid a little
bit of groundwork in that direction (Ian's vector insert/extract
series).

Looks like your backend already does SSA. Shouldn't that be
implemented in common code? :)

> It would be really nice to have more, useful device-independent
> optimizations or simplifications like this already done instead of
> requiring each driver to re-implement them (or use llvm).

Yes, it definitely would.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to