On 2/27/24 13:30, Greg McGary wrote:
On 2/27/24 8:25 AM, Jeff Law wrote:



On 2/25/24 21:53, Greg McGary wrote:
Add option -m(no-)autovec-segment to enable/disable autovectorizer
from emitting vector segment load/store instructions. This is useful for
performance experiments.

gcc/ChangeLog:
    * config/riscv/autovec.md (vec_mask_len_load_lanes, vec_mask_len_store_lanes):
      Predicate with TARGET_VECTOR_AUTOVEC_SEGMENT
    * gcc/config/riscv/riscv-opts.h (TARGET_VECTOR_AUTOVEC_SEGMENT): New macro.
    * gcc/config/riscv/riscv.opt (-m(no-)autovec-segment): New option.
    * gcc/tree-vect-stmts.cc (gcc/tree-vect-stmts.cc): Prevent divide-by-zero.
    * testsuite/gcc.target/riscv/rvv/autovec/struct/*_noseg*.c,
    testsuite/gcc.target/riscv/rvv/autovec/no-segment.c: New tests.
I don't mind having options to do this kind of selection (we've done similar things internally for other RVV features).  But I don't think now is the time to be introducing this stuff.  We're in stage4 of the development cycle after all.


No problemo. Will you take the simple bugfix?

   gcc/tree-vect-stmts.cc (gcc/tree-vect-stmts.cc): Prevent divide-by-zero.
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc

index 1dbe1115da4..6303d82d959 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -11521,7 +11521,8 @@ vectorizable_load (vec_info *vinfo,
                   - (vec_num * j + i) * nunits);
                  /* remain should now be > 0 and < nunits.  */
                  unsigned num;
-                if (constant_multiple_p (nunits, remain, &num))
+                if (known_gt (remain, 0)
+                && constant_multiple_p (nunits, remain, &num))
                    {
                  tree ptype;
                  new_vtype


I am unaware of a testcase that triggers it without disabling segmented load, so LMK if you are cool with the fix without a test case.
We'd really need a testcase and some analysis -- this change will affect every target, so you'd need to explain why the change is correct.

jeff

Reply via email to