Re: [Mesa-dev] [PATCH 1/7] glsl: Separate overlapping sentinel nodes in exec_list.
There are a couple nits and suggestions for small follow-ups below. With the couple nits (all in ast_to_hir.cpp) fixed, this patch is Reviewed-by: Ian RomanickOn 07/08/2016 03:18 PM, Matt Turner wrote: > I do appreciate the cleverness, but unfortunately it prevents a lot more > cleverness in the form of additional compiler optimizations brought on > by -fstrict-aliasing. > > No difference in OglBatch7 (n=20). > > Co-authored-by: Davin McCall > --- > I took Ian's suggestion to add get_head_raw() and get_tail_raw() methods > and use them in place of head_sentinel.next and tail_sentinel.prev. > > src/compiler/glsl/ast.h| 4 +- > src/compiler/glsl/ast_function.cpp | 22 +-- > src/compiler/glsl/ast_to_hir.cpp | 6 +- > src/compiler/glsl/ast_type.cpp | 2 +- > src/compiler/glsl/glsl_parser_extras.cpp | 6 +- > src/compiler/glsl/ir.cpp | 8 +- > src/compiler/glsl/ir_clone.cpp | 2 +- > src/compiler/glsl/ir_constant_expression.cpp | 2 +- > src/compiler/glsl/ir_function.cpp | 14 +- > src/compiler/glsl/ir_reader.cpp| 4 +- > src/compiler/glsl/ir_validate.cpp | 4 +- > src/compiler/glsl/list.h | 184 > - > src/compiler/glsl/lower_distance.cpp | 4 +- > src/compiler/glsl/lower_jumps.cpp | 2 +- > src/compiler/glsl/lower_packed_varyings.cpp| 8 +- > src/compiler/glsl/lower_tess_level.cpp | 4 +- > src/compiler/glsl/opt_conditional_discard.cpp | 6 +- > src/compiler/glsl/opt_dead_builtin_varyings.cpp| 2 +- > src/compiler/glsl/opt_dead_code.cpp| 2 +- > src/compiler/glsl/opt_flatten_nested_if_blocks.cpp | 2 +- > src/compiler/nir/nir.h | 4 +- > src/compiler/nir/nir_opt_gcm.c | 2 +- > src/mesa/drivers/dri/i965/brw_cfg.h| 2 +- > src/mesa/drivers/dri/i965/brw_fs_builder.h | 2 +- > src/mesa/drivers/dri/i965/brw_vec4_builder.h | 2 +- > 25 files changed, 164 insertions(+), 136 deletions(-) > > diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h > index 06c7b03..fa5a731 100644 > --- a/src/compiler/glsl/ast.h > +++ b/src/compiler/glsl/ast.h > @@ -346,8 +346,8 @@ public: > > bool is_single_dimension() const > { > - return this->array_dimensions.tail_pred->prev != NULL && > - this->array_dimensions.tail_pred->prev->is_head_sentinel(); > + return this->array_dimensions.get_tail_raw()->prev != NULL && > + this->array_dimensions.get_tail_raw()->is_head_sentinel(); > } > > virtual void print(void) const; > diff --git a/src/compiler/glsl/ast_function.cpp > b/src/compiler/glsl/ast_function.cpp > index f74394f..9dcec50 100644 > --- a/src/compiler/glsl/ast_function.cpp > +++ b/src/compiler/glsl/ast_function.cpp > @@ -186,8 +186,8 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, > exec_list _ir_parameters, > exec_list _ast_parameters) > { > - exec_node *actual_ir_node = actual_ir_parameters.head; > - exec_node *actual_ast_node = actual_ast_parameters.head; > + exec_node *actual_ir_node = actual_ir_parameters.get_head_raw(); > + exec_node *actual_ast_node = actual_ast_parameters.get_head_raw(); > > foreach_in_list(const ir_variable, formal, >parameters) { >/* The lists must be the same length. */ > @@ -318,10 +318,12 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, > const char *func_name = sig->function_name(); > bool is_atomic = is_atomic_function(func_name); > if (is_atomic) { > - const ir_rvalue *const actual = (ir_rvalue *) > actual_ir_parameters.head; > + const ir_rvalue *const actual = > + (ir_rvalue *) actual_ir_parameters.get_head_raw(); > >const ast_expression *const actual_ast = > - exec_node_data(ast_expression, actual_ast_parameters.head, link); > + exec_node_data(ast_expression, > +actual_ast_parameters.get_head_raw(), link); >YYLTYPE loc = actual_ast->get_location(); > >if (!verify_first_atomic_parameter(, state, > @@ -1176,7 +1178,7 @@ constant_record_constructor(const glsl_type > *constructor_type, > bool > single_scalar_parameter(exec_list *parameters) > { > - const ir_rvalue *const p = (ir_rvalue *) parameters->head; > + const ir_rvalue *const p = (ir_rvalue *) parameters->get_head_raw(); > assert(((ir_rvalue *)p)->as_rvalue() != NULL); > > return (p->type->is_scalar() && p->next->is_tail_sentinel()); > @@ -1220,7 +1222,7 @@ emit_inline_vector_constructor(const glsl_type *type, > */ > const unsigned lhs_components = type->components(); > if
Re: [Mesa-dev] [PATCH 1/7] glsl: Separate overlapping sentinel nodes in exec_list.
ping ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/7] glsl: Separate overlapping sentinel nodes in exec_list.
On Fri, Jul 8, 2016 at 3:18 PM, Matt Turnerwrote: > I do appreciate the cleverness, but unfortunately it prevents a lot more > cleverness in the form of additional compiler optimizations brought on > by -fstrict-aliasing. > > No difference in OglBatch7 (n=20). > > Co-authored-by: Davin McCall > --- > I took Ian's suggestion to add get_head_raw() and get_tail_raw() methods > and use them in place of head_sentinel.next and tail_sentinel.prev. > > src/compiler/glsl/ast.h| 4 +- > src/compiler/glsl/ast_function.cpp | 22 +-- > src/compiler/glsl/ast_to_hir.cpp | 6 +- > src/compiler/glsl/ast_type.cpp | 2 +- > src/compiler/glsl/glsl_parser_extras.cpp | 6 +- > src/compiler/glsl/ir.cpp | 8 +- > src/compiler/glsl/ir_clone.cpp | 2 +- > src/compiler/glsl/ir_constant_expression.cpp | 2 +- > src/compiler/glsl/ir_function.cpp | 14 +- > src/compiler/glsl/ir_reader.cpp| 4 +- > src/compiler/glsl/ir_validate.cpp | 4 +- > src/compiler/glsl/list.h | 184 > - > src/compiler/glsl/lower_distance.cpp | 4 +- > src/compiler/glsl/lower_jumps.cpp | 2 +- > src/compiler/glsl/lower_packed_varyings.cpp| 8 +- > src/compiler/glsl/lower_tess_level.cpp | 4 +- > src/compiler/glsl/opt_conditional_discard.cpp | 6 +- > src/compiler/glsl/opt_dead_builtin_varyings.cpp| 2 +- > src/compiler/glsl/opt_dead_code.cpp| 2 +- > src/compiler/glsl/opt_flatten_nested_if_blocks.cpp | 2 +- > src/compiler/nir/nir.h | 4 +- > src/compiler/nir/nir_opt_gcm.c | 2 +- > src/mesa/drivers/dri/i965/brw_cfg.h| 2 +- > src/mesa/drivers/dri/i965/brw_fs_builder.h | 2 +- > src/mesa/drivers/dri/i965/brw_vec4_builder.h | 2 +- > 25 files changed, 164 insertions(+), 136 deletions(-) > > diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h > index 06c7b03..fa5a731 100644 > --- a/src/compiler/glsl/ast.h > +++ b/src/compiler/glsl/ast.h > @@ -346,8 +346,8 @@ public: > > bool is_single_dimension() const > { > - return this->array_dimensions.tail_pred->prev != NULL && > - this->array_dimensions.tail_pred->prev->is_head_sentinel(); > + return this->array_dimensions.get_tail_raw()->prev != NULL && > + this->array_dimensions.get_tail_raw()->is_head_sentinel(); There's a missing ->prev on this line. Fixed locally, and passes Jenkins. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/7] glsl: Separate overlapping sentinel nodes in exec_list.
I do appreciate the cleverness, but unfortunately it prevents a lot more cleverness in the form of additional compiler optimizations brought on by -fstrict-aliasing. No difference in OglBatch7 (n=20). Co-authored-by: Davin McCall--- I took Ian's suggestion to add get_head_raw() and get_tail_raw() methods and use them in place of head_sentinel.next and tail_sentinel.prev. src/compiler/glsl/ast.h| 4 +- src/compiler/glsl/ast_function.cpp | 22 +-- src/compiler/glsl/ast_to_hir.cpp | 6 +- src/compiler/glsl/ast_type.cpp | 2 +- src/compiler/glsl/glsl_parser_extras.cpp | 6 +- src/compiler/glsl/ir.cpp | 8 +- src/compiler/glsl/ir_clone.cpp | 2 +- src/compiler/glsl/ir_constant_expression.cpp | 2 +- src/compiler/glsl/ir_function.cpp | 14 +- src/compiler/glsl/ir_reader.cpp| 4 +- src/compiler/glsl/ir_validate.cpp | 4 +- src/compiler/glsl/list.h | 184 - src/compiler/glsl/lower_distance.cpp | 4 +- src/compiler/glsl/lower_jumps.cpp | 2 +- src/compiler/glsl/lower_packed_varyings.cpp| 8 +- src/compiler/glsl/lower_tess_level.cpp | 4 +- src/compiler/glsl/opt_conditional_discard.cpp | 6 +- src/compiler/glsl/opt_dead_builtin_varyings.cpp| 2 +- src/compiler/glsl/opt_dead_code.cpp| 2 +- src/compiler/glsl/opt_flatten_nested_if_blocks.cpp | 2 +- src/compiler/nir/nir.h | 4 +- src/compiler/nir/nir_opt_gcm.c | 2 +- src/mesa/drivers/dri/i965/brw_cfg.h| 2 +- src/mesa/drivers/dri/i965/brw_fs_builder.h | 2 +- src/mesa/drivers/dri/i965/brw_vec4_builder.h | 2 +- 25 files changed, 164 insertions(+), 136 deletions(-) diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h index 06c7b03..fa5a731 100644 --- a/src/compiler/glsl/ast.h +++ b/src/compiler/glsl/ast.h @@ -346,8 +346,8 @@ public: bool is_single_dimension() const { - return this->array_dimensions.tail_pred->prev != NULL && - this->array_dimensions.tail_pred->prev->is_head_sentinel(); + return this->array_dimensions.get_tail_raw()->prev != NULL && + this->array_dimensions.get_tail_raw()->is_head_sentinel(); } virtual void print(void) const; diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp index f74394f..9dcec50 100644 --- a/src/compiler/glsl/ast_function.cpp +++ b/src/compiler/glsl/ast_function.cpp @@ -186,8 +186,8 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, exec_list _ir_parameters, exec_list _ast_parameters) { - exec_node *actual_ir_node = actual_ir_parameters.head; - exec_node *actual_ast_node = actual_ast_parameters.head; + exec_node *actual_ir_node = actual_ir_parameters.get_head_raw(); + exec_node *actual_ast_node = actual_ast_parameters.get_head_raw(); foreach_in_list(const ir_variable, formal, >parameters) { /* The lists must be the same length. */ @@ -318,10 +318,12 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, const char *func_name = sig->function_name(); bool is_atomic = is_atomic_function(func_name); if (is_atomic) { - const ir_rvalue *const actual = (ir_rvalue *) actual_ir_parameters.head; + const ir_rvalue *const actual = + (ir_rvalue *) actual_ir_parameters.get_head_raw(); const ast_expression *const actual_ast = - exec_node_data(ast_expression, actual_ast_parameters.head, link); + exec_node_data(ast_expression, +actual_ast_parameters.get_head_raw(), link); YYLTYPE loc = actual_ast->get_location(); if (!verify_first_atomic_parameter(, state, @@ -1176,7 +1178,7 @@ constant_record_constructor(const glsl_type *constructor_type, bool single_scalar_parameter(exec_list *parameters) { - const ir_rvalue *const p = (ir_rvalue *) parameters->head; + const ir_rvalue *const p = (ir_rvalue *) parameters->get_head_raw(); assert(((ir_rvalue *)p)->as_rvalue() != NULL); return (p->type->is_scalar() && p->next->is_tail_sentinel()); @@ -1220,7 +1222,7 @@ emit_inline_vector_constructor(const glsl_type *type, */ const unsigned lhs_components = type->components(); if (single_scalar_parameter(parameters)) { - ir_rvalue *first_param = (ir_rvalue *)parameters->head; + ir_rvalue *first_param = (ir_rvalue *)parameters->get_head_raw(); ir_rvalue *rhs = new(ctx) ir_swizzle(first_param, 0, 0, 0, 0, lhs_components); ir_dereference_variable *lhs = new(ctx) ir_dereference_variable(var); @@ -1421,7 +1423,7 @@
Re: [Mesa-dev] [PATCH 1/7] glsl: Separate overlapping sentinel nodes in exec_list.
On 06/27/2016 02:42 PM, Matt Turner wrote: > I do appreciate the cleverness, but unfortunately it prevents a lot more > cleverness in the form of additional compiler optimizations brought on > by -fstrict-aliasing. > > No difference in OglBatch7 (n=20). > > Co-authored-by: Davin McCall> --- > src/compiler/glsl/ast.h| 4 +- > src/compiler/glsl/ast_function.cpp | 22 ++-- > src/compiler/glsl/ast_to_hir.cpp | 6 +- > src/compiler/glsl/ast_type.cpp | 2 +- > src/compiler/glsl/glsl_parser_extras.cpp | 6 +- > src/compiler/glsl/ir.cpp | 8 +- > src/compiler/glsl/ir_clone.cpp | 2 +- > src/compiler/glsl/ir_constant_expression.cpp | 2 +- > src/compiler/glsl/ir_function.cpp | 14 +-- > src/compiler/glsl/ir_reader.cpp| 4 +- > src/compiler/glsl/ir_validate.cpp | 4 +- > src/compiler/glsl/list.h | 136 > + > src/compiler/glsl/lower_distance.cpp | 4 +- > src/compiler/glsl/lower_jumps.cpp | 2 +- > src/compiler/glsl/lower_packed_varyings.cpp| 8 +- > src/compiler/glsl/lower_tess_level.cpp | 4 +- > src/compiler/glsl/opt_conditional_discard.cpp | 6 +- > src/compiler/glsl/opt_dead_builtin_varyings.cpp| 2 +- > src/compiler/glsl/opt_dead_code.cpp| 2 +- > src/compiler/glsl/opt_flatten_nested_if_blocks.cpp | 2 +- > src/compiler/nir/nir.h | 4 +- > src/compiler/nir/nir_opt_gcm.c | 2 +- > src/mesa/drivers/dri/i965/brw_cfg.h| 2 +- > src/mesa/drivers/dri/i965/brw_fs_builder.h | 2 +- > src/mesa/drivers/dri/i965/brw_vec4_builder.h | 2 +- > 25 files changed, 116 insertions(+), 136 deletions(-) > > diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h > index 06c7b03..5029ba7 100644 > --- a/src/compiler/glsl/ast.h > +++ b/src/compiler/glsl/ast.h > @@ -346,8 +346,8 @@ public: > > bool is_single_dimension() const > { > - return this->array_dimensions.tail_pred->prev != NULL && > - this->array_dimensions.tail_pred->prev->is_head_sentinel(); > + return this->array_dimensions.tail_sentinel.prev->prev != NULL && > + > this->array_dimensions.tail_sentinel.prev->prev->is_head_sentinel(); > } > > virtual void print(void) const; > diff --git a/src/compiler/glsl/ast_function.cpp > b/src/compiler/glsl/ast_function.cpp > index f74394f..41b0765 100644 > --- a/src/compiler/glsl/ast_function.cpp > +++ b/src/compiler/glsl/ast_function.cpp > @@ -186,8 +186,8 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, > exec_list _ir_parameters, > exec_list _ast_parameters) > { > - exec_node *actual_ir_node = actual_ir_parameters.head; > - exec_node *actual_ast_node = actual_ast_parameters.head; > + exec_node *actual_ir_node = actual_ir_parameters.head_sentinel.next; > + exec_node *actual_ast_node = actual_ast_parameters.head_sentinel.next; This seems pretty annoying. I've had this reply sitting open since Tuesday morning... and I don't have a good solution. Normally you'd add a function or macro to wrap this, but we already have exec_list::get_head. That function has the extra semantic that if the list is empty, you get NULL. Most of the places that don't already use that method don't want to use it. They either already know that the list is not empty (as a precondition) or they're going to compare the node pointer with the sentinel. We could add another function... but what do you call it, and how do you keep people from using the wrong one? get_head_raw()? get_head_fast()? _head()? first()? Hmm... maybe change the existing functions to get_first_node() / get_last_node() and call the new functions get_head() / get_tail()? All I know is that I really don't want to type head_sentinel.next or tail_sentinel.prev... mostly because at least once I'll accidentally type (or cut-and-paste, or search-and-replace) tail_sentinel.next, and I'll never find the bug. Anyway... patches 2/7 are Reviewed-by: Ian Romanick I'd like to have some kind of improvement here, but I think the mechanics of the change are correct. > foreach_in_list(const ir_variable, formal, >parameters) { >/* The lists must be the same length. */ > @@ -318,10 +318,12 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, > const char *func_name = sig->function_name(); > bool is_atomic = is_atomic_function(func_name); > if (is_atomic) { > - const ir_rvalue *const actual = (ir_rvalue *) > actual_ir_parameters.head; > + const ir_rvalue *const actual = > + (ir_rvalue *) actual_ir_parameters.head_sentinel.next; > >
[Mesa-dev] [PATCH 1/7] glsl: Separate overlapping sentinel nodes in exec_list.
I do appreciate the cleverness, but unfortunately it prevents a lot more cleverness in the form of additional compiler optimizations brought on by -fstrict-aliasing. No difference in OglBatch7 (n=20). Co-authored-by: Davin McCall--- src/compiler/glsl/ast.h| 4 +- src/compiler/glsl/ast_function.cpp | 22 ++-- src/compiler/glsl/ast_to_hir.cpp | 6 +- src/compiler/glsl/ast_type.cpp | 2 +- src/compiler/glsl/glsl_parser_extras.cpp | 6 +- src/compiler/glsl/ir.cpp | 8 +- src/compiler/glsl/ir_clone.cpp | 2 +- src/compiler/glsl/ir_constant_expression.cpp | 2 +- src/compiler/glsl/ir_function.cpp | 14 +-- src/compiler/glsl/ir_reader.cpp| 4 +- src/compiler/glsl/ir_validate.cpp | 4 +- src/compiler/glsl/list.h | 136 + src/compiler/glsl/lower_distance.cpp | 4 +- src/compiler/glsl/lower_jumps.cpp | 2 +- src/compiler/glsl/lower_packed_varyings.cpp| 8 +- src/compiler/glsl/lower_tess_level.cpp | 4 +- src/compiler/glsl/opt_conditional_discard.cpp | 6 +- src/compiler/glsl/opt_dead_builtin_varyings.cpp| 2 +- src/compiler/glsl/opt_dead_code.cpp| 2 +- src/compiler/glsl/opt_flatten_nested_if_blocks.cpp | 2 +- src/compiler/nir/nir.h | 4 +- src/compiler/nir/nir_opt_gcm.c | 2 +- src/mesa/drivers/dri/i965/brw_cfg.h| 2 +- src/mesa/drivers/dri/i965/brw_fs_builder.h | 2 +- src/mesa/drivers/dri/i965/brw_vec4_builder.h | 2 +- 25 files changed, 116 insertions(+), 136 deletions(-) diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h index 06c7b03..5029ba7 100644 --- a/src/compiler/glsl/ast.h +++ b/src/compiler/glsl/ast.h @@ -346,8 +346,8 @@ public: bool is_single_dimension() const { - return this->array_dimensions.tail_pred->prev != NULL && - this->array_dimensions.tail_pred->prev->is_head_sentinel(); + return this->array_dimensions.tail_sentinel.prev->prev != NULL && + this->array_dimensions.tail_sentinel.prev->prev->is_head_sentinel(); } virtual void print(void) const; diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp index f74394f..41b0765 100644 --- a/src/compiler/glsl/ast_function.cpp +++ b/src/compiler/glsl/ast_function.cpp @@ -186,8 +186,8 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, exec_list _ir_parameters, exec_list _ast_parameters) { - exec_node *actual_ir_node = actual_ir_parameters.head; - exec_node *actual_ast_node = actual_ast_parameters.head; + exec_node *actual_ir_node = actual_ir_parameters.head_sentinel.next; + exec_node *actual_ast_node = actual_ast_parameters.head_sentinel.next; foreach_in_list(const ir_variable, formal, >parameters) { /* The lists must be the same length. */ @@ -318,10 +318,12 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, const char *func_name = sig->function_name(); bool is_atomic = is_atomic_function(func_name); if (is_atomic) { - const ir_rvalue *const actual = (ir_rvalue *) actual_ir_parameters.head; + const ir_rvalue *const actual = + (ir_rvalue *) actual_ir_parameters.head_sentinel.next; const ast_expression *const actual_ast = - exec_node_data(ast_expression, actual_ast_parameters.head, link); + exec_node_data(ast_expression, +actual_ast_parameters.head_sentinel.next, link); YYLTYPE loc = actual_ast->get_location(); if (!verify_first_atomic_parameter(, state, @@ -1176,7 +1178,7 @@ constant_record_constructor(const glsl_type *constructor_type, bool single_scalar_parameter(exec_list *parameters) { - const ir_rvalue *const p = (ir_rvalue *) parameters->head; + const ir_rvalue *const p = (ir_rvalue *) parameters->head_sentinel.next; assert(((ir_rvalue *)p)->as_rvalue() != NULL); return (p->type->is_scalar() && p->next->is_tail_sentinel()); @@ -1220,7 +1222,7 @@ emit_inline_vector_constructor(const glsl_type *type, */ const unsigned lhs_components = type->components(); if (single_scalar_parameter(parameters)) { - ir_rvalue *first_param = (ir_rvalue *)parameters->head; + ir_rvalue *first_param = (ir_rvalue *)parameters->head_sentinel.next; ir_rvalue *rhs = new(ctx) ir_swizzle(first_param, 0, 0, 0, 0, lhs_components); ir_dereference_variable *lhs = new(ctx) ir_dereference_variable(var); @@ -1421,7 +1423,7 @@ emit_inline_matrix_constructor(const glsl_type *type, *to the upper left portion of the constructed matrix, and the remaining