Message ID | 20211007195456.1168070-6-richard.henderson@linaro.org |
---|---|
State | New |
Headers | show |
Series | tcg: optimize redundant sign extensions | expand |
Richard Henderson <richard.henderson@linaro.org> writes: > This will expose the variable to subroutines that > will be broken out of tcg_optimize. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > tcg/optimize.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/tcg/optimize.c b/tcg/optimize.c > index 627a5b39f6..b875d76354 100644 > --- a/tcg/optimize.c > +++ b/tcg/optimize.c > @@ -46,6 +46,7 @@ typedef struct TempOptInfo { > > typedef struct OptContext { > TCGContext *tcg; > + TCGOp *prev_mb; > TCGTempSet temps_used; > } OptContext; > > @@ -609,7 +610,7 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) > void tcg_optimize(TCGContext *s) > { > int nb_temps, nb_globals, i; > - TCGOp *op, *op_next, *prev_mb = NULL; > + TCGOp *op, *op_next; > OptContext ctx = { .tcg = s }; Do we need to add .prev_mb = NULL to ensure the ctx doesn't start corrupted or does the partial initialisation ensure the rest is zeroed out? Otherwise: Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
On 10/19/21 8:44 AM, Alex Bennée wrote: >> @@ -609,7 +610,7 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) >> void tcg_optimize(TCGContext *s) >> { >> int nb_temps, nb_globals, i; >> - TCGOp *op, *op_next, *prev_mb = NULL; >> + TCGOp *op, *op_next; >> OptContext ctx = { .tcg = s }; > > Do we need to add .prev_mb = NULL to ensure the ctx doesn't start > corrupted or does the partial initialisation ensure the rest is zeroed > out? All members not explicitly initialized are zeroed. > > Otherwise: > > Reviewed-by: Alex Bennée <alex.bennee@linaro.org> > r~
From: Richard Henderson <richard.henderson@linaro.org> > This will expose the variable to subroutines that will be broken out of > tcg_optimize. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > tcg/optimize.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) Reviewed-by: Luis Pires <luis.pires@eldorado.org.br> -- Luis Pires Instituto de Pesquisas ELDORADO Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
diff --git a/tcg/optimize.c b/tcg/optimize.c index 627a5b39f6..b875d76354 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -46,6 +46,7 @@ typedef struct TempOptInfo { typedef struct OptContext { TCGContext *tcg; + TCGOp *prev_mb; TCGTempSet temps_used; } OptContext; @@ -609,7 +610,7 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) void tcg_optimize(TCGContext *s) { int nb_temps, nb_globals, i; - TCGOp *op, *op_next, *prev_mb = NULL; + TCGOp *op, *op_next; OptContext ctx = { .tcg = s }; /* Array VALS has an element for each temp. @@ -1566,7 +1567,7 @@ void tcg_optimize(TCGContext *s) } /* Eliminate duplicate and redundant fence instructions. */ - if (prev_mb) { + if (ctx.prev_mb) { switch (opc) { case INDEX_op_mb: /* Merge two barriers of the same type into one, @@ -1580,7 +1581,7 @@ void tcg_optimize(TCGContext *s) * barrier. This is stricter than specified but for * the purposes of TCG is better than not optimizing. */ - prev_mb->args[0] |= op->args[0]; + ctx.prev_mb->args[0] |= op->args[0]; tcg_op_remove(s, op); break; @@ -1597,11 +1598,11 @@ void tcg_optimize(TCGContext *s) case INDEX_op_qemu_st_i64: case INDEX_op_call: /* Opcodes that touch guest memory stop the optimization. */ - prev_mb = NULL; + ctx.prev_mb = NULL; break; } } else if (opc == INDEX_op_mb) { - prev_mb = op; + ctx.prev_mb = op; } } }
This will expose the variable to subroutines that will be broken out of tcg_optimize. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- tcg/optimize.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)