diff --git a/src/gallium/drivers/r300/compiler/radeon_variable.c b/src/gallium/drivers/r300/compiler/radeon_variable.c index 5cd9485094e..615cd31ae89 100644 --- a/src/gallium/drivers/r300/compiler/radeon_variable.c +++ b/src/gallium/drivers/r300/compiler/radeon_variable.c @@ -486,21 +486,28 @@ rc_variable_list_get_writers(struct rc_list *var_list, unsigned int src_type, vo struct rc_list *writer_list = NULL; for (list_ptr = var_list; list_ptr; list_ptr = list_ptr->Next) { struct rc_variable *var = list_ptr->Item; - if (variable_writes_src(var, src_type, src)) { - struct rc_variable *friend; - rc_list_add(&writer_list, rc_list(&var->C->Pool, var)); - for (friend = var->Friend; friend; friend = friend->Friend) { - if (variable_writes_src(friend, src_type, src)) { - rc_list_add(&writer_list, rc_list(&var->C->Pool, friend)); + while (var) { + if (variable_writes_src(var, src_type, src)) { + struct rc_variable *friend; + rc_list_add(&writer_list, rc_list(&var->C->Pool, var)); + for (friend = var->Friend; friend; friend = friend->Friend) { + if (variable_writes_src(friend, src_type, src)) { + rc_list_add(&writer_list, rc_list(&var->C->Pool, friend)); + } } + /* Once we have identified the variable and its + * friends that write this source, we can stop + * stop searching, because we know none of the + * other variables in the list will write this source. + * If they did they would be friends of var. + */ + return writer_list; + } else { + if (var->Friend) + var = var->Friend; + else + break; } - /* Once we have identified the variable and its - * friends that write this source, we can stop - * stop searching, because we know none of the - * other variables in the list will write this source. - * If they did they would be friends of var. - */ - break; } } return writer_list;