Fixed conditional move tcg bug (tcg_gen_movcond), which generated an ALWAYS / NEVER condition despite QEMU no supporting those conditions in the tcg_out part (#1054)

This commit is contained in:
dmarxn
2019-01-31 03:59:51 +02:00
committed by Nguyen Anh Quynh
parent 8c6cbe3f3c
commit 3df5ef8ab1

View File

@ -2195,7 +2195,12 @@ static inline void tcg_gen_movcond_i32(TCGContext *s, TCGCond cond, TCGv_i32 ret
TCGv_i32 c1, TCGv_i32 c2, TCGv_i32 c1, TCGv_i32 c2,
TCGv_i32 v1, TCGv_i32 v2) TCGv_i32 v1, TCGv_i32 v2)
{ {
if (TCG_TARGET_HAS_movcond_i32) { if (cond == TCG_COND_ALWAYS) {
tcg_gen_mov_i32(s, ret, v1);
} else if (cond == TCG_COND_NEVER) {
tcg_gen_mov_i32(s, ret, v2);
}
else if (TCG_TARGET_HAS_movcond_i32) {
tcg_gen_op6i_i32(s, INDEX_op_movcond_i32, ret, c1, c2, v1, v2, cond); tcg_gen_op6i_i32(s, INDEX_op_movcond_i32, ret, c1, c2, v1, v2, cond);
} else { } else {
TCGv_i32 t0 = tcg_temp_new_i32(s); TCGv_i32 t0 = tcg_temp_new_i32(s);
@ -2214,6 +2219,12 @@ static inline void tcg_gen_movcond_i64(TCGContext *s, TCGCond cond, TCGv_i64 ret
TCGv_i64 c1, TCGv_i64 c2, TCGv_i64 c1, TCGv_i64 c2,
TCGv_i64 v1, TCGv_i64 v2) TCGv_i64 v1, TCGv_i64 v2)
{ {
if (cond == TCG_COND_ALWAYS) {
tcg_gen_mov_i64(s, ret, v1);
} else if (cond == TCG_COND_NEVER) {
tcg_gen_mov_i64(s, ret, v2);
}
else {
#if TCG_TARGET_REG_BITS == 32 #if TCG_TARGET_REG_BITS == 32
TCGv_i32 t0 = tcg_temp_new_i32(s); TCGv_i32 t0 = tcg_temp_new_i32(s);
TCGv_i32 t1 = tcg_temp_new_i32(s); TCGv_i32 t1 = tcg_temp_new_i32(s);
@ -2240,7 +2251,7 @@ static inline void tcg_gen_movcond_i64(TCGContext *s, TCGCond cond, TCGv_i64 ret
} }
tcg_temp_free_i32(s, t0); tcg_temp_free_i32(s, t0);
tcg_temp_free_i32(s, t1); tcg_temp_free_i32(s, t1);
#else #else
if (TCG_TARGET_HAS_movcond_i64) { if (TCG_TARGET_HAS_movcond_i64) {
tcg_gen_op6i_i64(s, INDEX_op_movcond_i64, ret, c1, c2, v1, v2, cond); tcg_gen_op6i_i64(s, INDEX_op_movcond_i64, ret, c1, c2, v1, v2, cond);
} else { } else {
@ -2255,6 +2266,7 @@ static inline void tcg_gen_movcond_i64(TCGContext *s, TCGCond cond, TCGv_i64 ret
tcg_temp_free_i64(s, t1); tcg_temp_free_i64(s, t1);
} }
#endif #endif
}
} }
static inline void tcg_gen_add2_i32(TCGContext *s, TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 al, static inline void tcg_gen_add2_i32(TCGContext *s, TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 al,