On 9/15/2025 9:53 PM, Richard Henderson wrote: > On 9/13/25 02:17, Chao Liu wrote: >> +static void gen_check_vext_elem_mask(TCGLabel *label, TCGv_i64 mask, >> TCGv_i64 >> mask_offs) >> +{ >> + TCGv_i64 mask_offs_i64 = tcg_temp_new_i64(); >> + TCGv_ptr mask_offs_ptr = tcg_temp_new_ptr(); >> + TCGv_i64 mask_offs_rem = tcg_temp_new_i64(); >> + TCGv_i64 mask_elem = tcg_temp_new_i64(); >> + >> + tcg_gen_shri_tl(mask_offs_i64, mask_offs, 3); >> + tcg_gen_add_tl(mask_offs_i64, mask_offs_i64, mask); >> + tcg_gen_trunc_i64_ptr(mask_offs_ptr, mask_offs_i64); >> + tcg_gen_ld_i64(mask_elem, mask_offs_ptr, 0); > > You can remove the "mask" argument, simplifying the code here. > > tcg_gen_trunc_i64_ptr(ptr, mask_offs_i64); > tcg_gen_add_ptr(ptr, ptr, tcg_env); > tcg_gen_ld_i64(mask_elem, ptr, vreg_ofs(s, 0)) > Thanks, I will try modifying it this way:
tcg_gen_shri_tl(temp, mask_offs, 3); tcg_gen_trunc_i64_ptr(ptr, temp); tcg_gen_add_ptr(ptr, ptr, tcg_env); Based on your suggestion, I have removed the `mask` args. > You can also change mask_offs to TCGv_i32, which replaces > > tcg_gen_extu_i32_ptr(pr, mask_offs_i32); > > which more obviously does not discard data from mask_offs. > > >> + tcg_gen_andi_tl(mask_offs_rem, mask_offs, 7); >> + tcg_gen_shr_tl(mask_elem, mask_elem, mask_offs_rem); > > The mask of 7 suggests you're only interested in the low 8 bits. Which means > either the load is wrong (we don't need to be loading 64 bits), or the mask > and > shift are wrong. > > Get, loading just one byte at a time is sufficient. I will modify it accordingly: tcg_gen_ld8u_i64(elem, ptr, 0); tcg_gen_andi_tl(temp, mask_offs, 7); tcg_gen_shr_tl(elem, elem, temp); >> + tcg_gen_andi_tl(mask_elem, mask_elem, 1); >> + tcg_gen_brcond_i64(TCG_COND_TSTNE, mask_elem, tcg_constant_i64(1), >> label); > > The andi before the brcond is redundant with the TSTNE. > Get~ > > r~ In addition, I also found other redundant parameters, such as the `vreg` argument in gen_ldst_vreg(). I will remove them together in the next version of the patch. Thanks, Chao