HAO CHEN GUI <guih...@linux.ibm.com> writes: > Kewen and Richard, > Thanks for your comments. Please let me clarify it. > > 在 2023/9/27 19:10, Richard Sandiford 写道: >> Yeah, I agree there doesn't seem to be a good reason to exclude vectors. >> Sorry to dive straight into details, but maybe we should have something >> called bitwise_mode_for_size that tries to use integer modes where possible, >> but falls back to vector modes otherwise. That mode could then be used >> for copying, storing, bitwise ops, and equality comparisons (if there >> is appropriate optabs support). > > The vector mode is not supported for compare_by_pieces and move_by_pieces. > But it is supported for set_by_pieces and clear_by_pieces. The help function > widest_fixed_size_mode_for_size returns vector mode when qi_vector is set to > true. > > static fixed_size_mode > widest_fixed_size_mode_for_size (unsigned int size, bool qi_vector)
Ah, had forgotten about that function. > > I tried to enable qi_vector for compare_by_pieces. It can pick up a vector > mode (eg. V16QImode) and works on some cases. But it fails on a constant > string case. > > int compare (const char* s1) > { > return __builtin_memcmp_eq (s1, "__GCC_HAVE_DWARF2_CFI_ASM", 16); > } > > As the second op is a constant string, it calls builtin_memcpy_read_str to > build the string. Unfortunately, the inner function doesn't support > vector mode. > > /* The by-pieces infrastructure does not try to pick a vector mode > for memcpy expansion. */ > return c_readstr (rep + offset, as_a <scalar_int_mode> (mode), > /*nul_terminated=*/false); > > Seems by-pieces infrastructure itself supports vector mode, but low level > functions do not. That looks easily solvable though. I've posted a potential fix as: https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631595.html Is that the only blocker to doing this in generic code? Thanks, Richard > > I think there are two ways enable vector mode for compare_by_pieces. > One is to modify the by-pieces infrastructure . Another is to enable it > by cmpmem expand. The expand is target specific and be flexible. > > What's your opinion? > > Thanks > Gui Haochen