Address comments. V5 patch: https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618398.html Thanks. juzhe.zhong@rivai.ai From: Kito Cheng Date: 2023-05-13 00:16 To: juzhe.zhong CC: gcc-patches; palmer; jeffreyalaw Subject: Re: [PATCH V4] RISC-V: Using merge approach to optimize repeating sequence in vec_init > +/* Get the mask for merge approach. > + > + Consider such following case: > + {a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b} > + To merge "a", the mask should be 1010.... > + To merge "b", the mask should be 0101.... > +*/ > +rtx > +rvv_builder::get_merge_mask_bitfield (unsigned int index) const > +{ > + uint64_t base_mask = (1ULL << index); > + uint64_t mask = 0; > + for (unsigned int i = 0; i < (64 / npatterns ()); i++) What the magic 64 means? ... > +static void > +expand_vector_init_merge_repeating_sequence (rtx target, > + const rvv_builder &builder) > +{ > + machine_mode mask_mode; > + gcc_assert (get_mask_mode (builder.mode ()).exists (&mask_mode)); > + > + machine_mode dup_mode = builder.mode (); > + if (known_gt (GET_MODE_SIZE (dup_mode), BYTES_PER_RISCV_VECTOR)) > + { > + poly_uint64 nunits > + = exact_div (BYTES_PER_RISCV_VECTOR, builder.inner_units ()); > + gcc_assert ( > + get_vector_mode (builder.inner_int_mode (), nunits).exists (&dup_mode)); gcc_assert will removed at release mode, so it's not you want I guess? > + } > + else > + { > + if (FLOAT_MODE_P (dup_mode)) > + gcc_assert (get_vector_mode (builder.inner_int_mode (), > + GET_MODE_NUNITS (dup_mode)) > + .exists (&dup_mode)); Same issue > + } > + > + machine_mode dup_mask_mode; > + gcc_assert (get_mask_mode (dup_mode).exists (&dup_mask_mode)); Same issue