tcg/s390x: fix constraint for 32-bit TSTEQ/TSTNE
PATCH 1/1 tcg/s390x: fix constraint for 32-bit TSTEQ/TSTNE
32-bit TSTEQ and TSTNE is subject to the same constraints as for 64-bit, but setcond_i32 and negsetcond_i32 were incorrectly using TCG_CT_CONST ("i") instead of TCG_CT_CONST_CMP ("C").
Adjust the constraint and make tcg_target_const_match use the same sequence as tgen_cmp2: first check if the constant is a valid operand for TSTEQ/TSTNE, then accept everything for 32-bit non-test comparisons, finally check if the constant is a valid operand for 64-bit non-test comparisons.
--- tcg/s390x/tcg-target.c.inc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
tcg/s390x/tcg-target.c.inc +16 -8
@@ -565,6 +565,20 @@ static bool tcg_target_const_match(int64_t val, int ct, } if (ct & TCG_CT_CONST_CMP) { + if (is_tst_cond(cond)) { + if (is_const_p16(uval) >= 0) { + return true; /* TMxx */ + } + if (risbg_mask(uval)) { + return true; /* RISBG */ + } + return false; + } + + if (type == TCG_TYPE_I32) { + return true; + } + switch (cond) { case TCG_COND_EQ: case TCG_COND_NE:
@@ -584,13 +598,7 @@ static bool tcg_target_const_match(int64_t val, int ct, break; case TCG_COND_TSTNE: case TCG_COND_TSTEQ: - if (is_const_p16(uval) >= 0) { - return true; /* TMxx */ - } - if (risbg_mask(uval)) { - return true; /* RISBG */ - } - break; + /* checked above, fallthru */ default: g_assert_not_reached(); }
@@ -3231,9 +3239,9 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_rotl_i64: case INDEX_op_rotr_i32: case INDEX_op_rotr_i64: + return C_O1_I2(r, r, ri); case INDEX_op_setcond_i32: case INDEX_op_negsetcond_i32: - return C_O1_I2(r, r, ri); case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i64: return C_O1_I2(r, r, rC);
Signature · 1 line
2.46.2
Quoted 5 lines · Paolo Bonzini
32-bit TSTEQ and TSTNE is subject to the same constraints as for 64-bit, but
setcond_i32andnegsetcond_i32were incorrectly usingTCG_CT_CONST("i") instead ofTCG_CT_CONST_CMP("C").
Quoted 8 lines
Adjust the constraint and make
tcg_target_const_matchuse the same sequence astgen_cmp2: first check if the constant is a valid operand for TSTEQ/TSTNE, then accept everything for 32-bit non-test comparisons, finally check if the constant is a valid operand for 64-bit non-test comparisons.Reported-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>
Should this cc stable? Does it cause any current problems? (AIUI the x86 target changes in your pending pullreq do trigger this.)
thanks
-- PMM
Quoted 12 lines · Peter Maydell
Quoted 11 lines · Paolo Bonzini
32-bit TSTEQ and TSTNE is subject to the same constraints as for 64-bit, but
setcond_i32andnegsetcond_i32were incorrectly usingTCG_CT_CONST("i") instead ofTCG_CT_CONST_CMP("C").Adjust the constraint and make
tcg_target_const_matchuse the same sequence astgen_cmp2: first check if the constant is a valid operand for TSTEQ/TSTNE, then accept everything for 32-bit non-test comparisons, finally check if the constant is a valid operand for 64-bit non-test comparisons.
Quoted 6 lines
Quoted 2 lines
Reported-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>Should this cc stable? Does it cause any current problems? (AIUI the x86 target changes in your pending pullreq do trigger this.)
Yeah, that's a good idea. It's probably possible to construct x86 code that triggers it (I'm surprised it wasn't found until now).
Paolo
Quoted 10 lines · Paolo Bonzini
32-bit TSTEQ and TSTNE is subject to the same constraints as for 64-bit, but
setcond_i32andnegsetcond_i32were incorrectly usingTCG_CT_CONST("i") instead ofTCG_CT_CONST_CMP("C").Adjust the constraint and make
tcg_target_const_matchuse the same sequence astgen_cmp2: first check if the constant is a valid operand for TSTEQ/TSTNE, then accept everything for 32-bit non-test comparisons, finally check if the constant is a valid operand for 64-bit non-test comparisons.
Quoted 5 lines
Reported-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Paolo Bonzini<[email protected]>--- tcg/s390x/tcg-target.c.inc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
r~
Quoted 10 lines · Paolo Bonzini
32-bit TSTEQ and TSTNE is subject to the same constraints as for 64-bit, but
setcond_i32andnegsetcond_i32were incorrectly usingTCG_CT_CONST("i") instead ofTCG_CT_CONST_CMP("C").Adjust the constraint and make
tcg_target_const_matchuse the same sequence astgen_cmp2: first check if the constant is a valid operand for TSTEQ/TSTNE, then accept everything for 32-bit non-test comparisons, finally check if the constant is a valid operand for 64-bit non-test comparisons.
Quoted 5 lines
Reported-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- tcg/s390x/tcg-target.c.inc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)