On 1/15/26 13:54, Paolo Bonzini wrote:
@@ -2628,8 +2638,18 @@ void tcg_gen_deposit_z_i64(TCGv_i64 ret, TCGv_i64 arg,
tcg_gen_extract_i64(ret, ret, 0, ofs + len);
return;
}
- tcg_gen_andi_i64(ret, arg, (1ull << len) - 1);
- tcg_gen_shli_i64(ret, ret, ofs);
+ /*
+ * Use TCG_TARGET_extract_valid to check for 8-, 16- and 32-bit
extension
+ * opcodes, which tcg_gen_andi_i64 can produce.
+ */
+ if (TCG_TARGET_extract_valid(TCG_TYPE_I64, 0, len) ||
+ tcg_op_imm_match(INDEX_op_and, TCG_TYPE_I64, (1ull << len) - 1)) {
+ tcg_gen_andi_i64(ret, arg, (1ull << len) - 1);
+ tcg_gen_shli_i64(ret, ret, ofs);
+ } else {
+ tcg_gen_shli_i64(ret, arg, 64 - len);
+ tcg_gen_shri_i64(ret, ret, 64 - len - ofs);
+ }
}
}
Also just a couple of coding standards issues - "Use
TCG_TARGET_extract_valid" comment is over 80 characters and you have a
tab at the start of the call to tcp_op_imm_match. Otherwise, looks good.
Jim