tcg/optimize: fix setcond2 optimization
PATCH 1/1 tcg/optimize: fix setcond2 optimization
When setcond2 is rewritten into setcond, the state of the destination temp should be reset, so that a copy of the previous value is not used instead of the result.
--- tcg/optimize.c | 1 + 1 file changed, 1 insertion(+)
tcg/optimize.c +1 -0
@@ -1057,6 +1057,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,/* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ s->gen_opc_buf[op_index] = INDEX_op_setcond_i32; +reset_temp (args[0 ]); gen_args[0 ] = args[0 ]; gen_args[1 ] = args[2 ]; gen_args[2 ] = args[4 ];
Signature · 1 line
1.7.10.4
Quoted 16 lines · Aurelien Jarno
When setcond2 is rewritten into setcond, the state of the destination temp should be reset, so that a copy of the previous value is not used instead of the result.
Reported-by Michael Tokarev <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>--- tcg/optimize.c | 1 + 1 file changed, 1 insertion(+)tcg/optimize.c +0
-0
tcg/optimize.c static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, · line 1063
Quoted 7 lines
tcg/optimize.c +1
-0@@ -1057,6 +1057,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,/* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ s->gen_opc_buf[op_index] = INDEX_op_setcond_i32; +reset_temp (args[0 ]); gen_args[0 ] = args[0 ]; gen_args[1 ] = args[2 ]; gen_args[2 ] = args[4 ];
I have just noticed that the problem is there since release 1.3, even if it appeared more clearly only with commit 7eb0cc85. All 64-bit targets on 32-bit hosts are possibly affected.
Therefore it should be fixed in the next stable releases. Hence the Cc to [email protected].
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 7 lines · Aurelien Jarno
When setcond2 is rewritten into setcond, the state of the destination temp should be reset, so that a copy of the previous value is not used instead of the result.
Reported-by Michael Tokarev <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>
r~