From: Jakub Jelinek Date: Fri, 8 May 2020 07:37:09 +0000 (+0200) Subject: tree: Avoid variable sharing in get_narrower [PR94724] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a139bc2b492de8a761890a5d299951dede3d8f7b;p=gcc.git tree: Avoid variable sharing in get_narrower [PR94724] On Thu, May 07, 2020 at 02:45:29PM +0200, Thomas Schwinge wrote: > >>+ for (tree op = win; TREE_CODE (op) == COMPOUND_EXPR; > > ..., and new 'op' variable here. > > >>+ op = TREE_OPERAND (op, 1)) > >>+ v.safe_push (op); > >>+ FOR_EACH_VEC_ELT_REVERSE (v, i, op) > >>+ ret = build2_loc (EXPR_LOCATION (op), COMPOUND_EXPR, > >>+ TREE_TYPE (win), TREE_OPERAND (op, 0), > >>+ ret); > >>+ return ret; > >> } > >> while (TREE_CODE (op) == NOP_EXPR) > >> { There is no reason for the shadowing and op at this point acts as a temporary and will be overwritten in FOR_EACH_VEC_ELT_REVERSE anyway. So, we can just s/tree // here. 2020-05-08 Jakub Jelinek PR middle-end/94724 * tree.c (get_narrower): Reuse the op temporary instead of shadowing it. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 75b0ed1542f..2e5a05134ab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2020-05-08 Jakub Jelinek + PR middle-end/94724 + * tree.c (get_narrower): Reuse the op temporary instead of + shadowing it. + PR tree-optimization/94783 * match.pd ((X + (X >> (prec - 1))) ^ (X >> (prec - 1)) to abs (X)): New simplification. diff --git a/gcc/tree.c b/gcc/tree.c index e451401822c..397474900ff 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -8889,7 +8889,7 @@ get_narrower (tree op, int *unsignedp_ptr) return win; auto_vec v; unsigned int i; - for (tree op = win; TREE_CODE (op) == COMPOUND_EXPR; + for (op = win; TREE_CODE (op) == COMPOUND_EXPR; op = TREE_OPERAND (op, 1)) v.safe_push (op); FOR_EACH_VEC_ELT_REVERSE (v, i, op)