On Wed, Dec 18, 2024 at 6:48 PM Robin Dapp <rdapp....@gmail.com> wrote: > > Hi, > > in PR116351 we try to vectorize with -march=...zve32x which does not > have 64-bit vector element sizes, don't find a proper mode and end up > using word_mode = DImode. > > vect_verify_loop_lens calls get_len_load_store_mode which asserts > VECTOR_MODE_P (vecmode) so DImode will cause an ICE. > > In check_load_store_for_partial_vectors we disable partial vectors > when emulating vectors so this patch does the same in tree-vect-loop.cc > before vect_verify_loop_lens is called. > > Is this the correct thing to do or should we have taken another > turn somewhere else?
else /* !LOOP_VINFO_LENS (loop_vinfo).is_empty () */ if (!vect_verify_loop_lens (loop_vinfo)) LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false; I wonder if LOOP_VINFO_LENS is really empty here? If not, who recorded the len and why did that not disable partial vectors? Maybe if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) && !LOOP_VINFO_MASKS (loop_vinfo).is_empty () && !LOOP_VINFO_LENS (loop_vinfo).is_empty ()) should become !(LOOP_VINFO_MASKS (loop_vinfo).is_empty () ^ LOOP_VINFO_LENS (loop_vinfo).is_empty ()))? > Bootstrapped and regtested on x86, aarch64, and power10. > Regtested on rv64gcv_zvl512b. > > Regards > Robin > > PR target/116351 > > gcc/ChangeLog: > > * tree-vect-loop.cc: Disable partial vectors for emulated > vectors. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/rvv/autovec/pr116351.c: New test. > --- > .../gcc.target/riscv/rvv/autovec/pr116351.c | 15 +++++++++++++++ > gcc/tree-vect-loop.cc | 10 ++++++++++ > 2 files changed, 25 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr116351.c > > diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr116351.c > b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr116351.c > new file mode 100644 > index 00000000000..ed1b985d8fa > --- /dev/null > +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr116351.c > @@ -0,0 +1,15 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O3 -march=rv64imd_zve32x -mrvv-vector-bits=zvl" } */ > + > +int a, b, c; > +short d, e, f; > +long (g) (long h) { return h; } > + > +void i () > +{ > + for (; b; ++b) > + { > + f = 5 >> a ? d : d << a; > + e &= c | g (f); > + } > +} > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc > index 4f401cd2d0c..2cf5a05b70c 100644 > --- a/gcc/tree-vect-loop.cc > +++ b/gcc/tree-vect-loop.cc > @@ -3021,6 +3021,16 @@ start_over: > LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false; > } > > + if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) > + && !VECTOR_MODE_P (loop_vinfo->vector_mode)) > + { > + if (dump_enabled_p ()) > + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > + "can't operate on partial vectors when emulating" > + " vector operations.\n"); > + LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false; > + } > + > /* If we still have the option of using partial vectors, > check whether we can generate the necessary loop controls. */ > if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)) > -- > 2.47.1 >