diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c index a977c57d2bda5b5c8063d03e8ffe7c2cf5b093d4..1526f2c2e71ef6f98f45364bd4eea26784cf0ce6 100644 --- a/tcg/sparc/tcg-target.c +++ b/tcg/sparc/tcg-target.c @@ -432,6 +432,11 @@ static void tcg_out_movi(TCGContext *s, TCGType type, { tcg_target_long hi, lo = (int32_t)arg; + /* Make sure we test 32-bit constants for imm13 properly. */ + if (type == TCG_TYPE_I32) { + arg = lo; + } + /* A 13-bit constant sign-extended to 64-bits. */ if (check_fit_tl(arg, 13)) { tcg_out_movi_imm13(s, ret, arg);