[Mesa-dev] [PATCH 07/11] glsl: Lower unconditional return statements.
Paul Berry
stereotype441 at gmail.com
Thu Jul 7 09:41:07 PDT 2011
On 7 July 2011 01:13, Kenneth Graunke <kenneth at whitecape.org> wrote:
>> visit_block(&ir->body);
>>
>> + /* If the body ended in an unconditional return of non-void,
>> + * then we don't need to lower it because an unconditional
>> + * return of non-void at the end of a function is what returns
>> + * get lowered to.
>
> This comment doesn't make sense to me. Are you trying to say that
> unconditional all non-void returns were already lowered to variable
> assignments and void returns? Or...?
Hmm, let me try again in more words:
When we are lowering returns in a function whose return type is void,
the goal is to rewrite the function so that it doesn't contain any
return instructions at all. However, when we are lowering returns in
a function whose return type is non-void, the goal is to rewrite the
function so that it contains a single return instruction, in canonical
position. (A return instruction is said to be in "canonical position"
if it is the last instruction in the function, and it's not inside any
ifs or loops).
If, after calling visit_block(&ir->body), the last instruction in the
function is a return instruction, and the return type of the function
is non-void, then we don't need to do anything, because the return
instruction is already in canonical position.
Let me know if that makes more sense, and I'll rewrite the comment accordingly.
More information about the mesa-dev
mailing list