[Mesa-dev] [PATCH] st/mesa: fix incorrect loop over instruction src regs

Bryan Cain bryancain3 at gmail.com
Wed Aug 17 07:49:20 PDT 2011


On 08/17/2011 09:47 AM, Keith Whitwell wrote:
> On Wed, 2011-08-17 at 09:36 -0500, Bryan Cain wrote:
>> The usual commit message prefix for changes to glsl_to_tgsi is
>> "glsl_to_tgsi", not "st/mesa".
>>
>> On 08/16/2011 05:33 PM, Brian Paul wrote:
>>> The array of src regs is of size 3, not 4.
>>> ---
>>>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> index aef23e7..7b90c81 100644
>>> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> @@ -3443,7 +3443,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void)
>>>           /* Continuing the block, clear any channels from the write array that
>>>            * are read by this instruction.
>>>            */
>>> -         for (int i = 0; i < 4; i++) {
>>> +         for (unsigned i = 0; i < Elements(inst->src); i++) {
>> Why not just use 3 here?
> Elements(inst->src) is self-documenting.  
>
> 3 is just a number and to figure out if it was the correct number you'd
> have to go and look at the header file to see if it matched the value
> there.
>
> Both should generate the same compiled code.
>
> Keith

Fair enough.  The patch was pushed to master shortly before I sent that
mail, so there's not much point in discussing it further.

Bryan



More information about the mesa-dev mailing list