]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Fix some dynamic LMUL costing.
authorRobin Dapp <rdapp@ventanamicro.com>
Fri, 7 Feb 2025 14:42:28 +0000 (15:42 +0100)
committerRobin Dapp <rdapp@ventanamicro.com>
Fri, 23 May 2025 14:59:31 +0000 (16:59 +0200)
With all-SLP we annotate statements slightly differently.  This patch
uses STMT_VINFO_RELEVANT_P in order to walk through potential program
points.

Also it makes the LMUL estimate always use the same path.  This helps
fix a number of test cases that regressed since GCC 14.

There are still some failing ones but it appears to me that the chosen
LMUL is still correct and we just expect different log messages.

gcc/ChangeLog:

* config/riscv/riscv-vector-costs.cc (compute_estimated_lmul):
Always use vect_vf_for_cost and TARGET_MIN_VLEN.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-3.c: Adjust
expectations.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-9.c: Ditto.

gcc/config/riscv/riscv-vector-costs.cc
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-3.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-9.c

index c28eecd1110e943e68f8fa9c9aa0e41392e7c613..a39b611e4cefca7f3c474d0d6e9eb4df0e5ed2c8 100644 (file)
@@ -205,9 +205,7 @@ compute_local_program_points (
              if (!is_gimple_assign_or_call (gsi_stmt (si)))
                continue;
              stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi_stmt (si));
-             enum stmt_vec_info_type type
-               = STMT_VINFO_TYPE (vect_stmt_to_vectorize (stmt_info));
-             if (type != undef_vec_info_type)
+             if (STMT_VINFO_RELEVANT_P (stmt_info))
                {
                  stmt_point info = {point, gsi_stmt (si), stmt_info};
                  program_points.safe_push (info);
@@ -626,7 +624,7 @@ compute_estimated_lmul (loop_vec_info loop_vinfo, machine_mode mode)
   int regno_alignment = riscv_get_v_regno_alignment (loop_vinfo->vector_mode);
   if (riscv_v_ext_vls_mode_p (loop_vinfo->vector_mode))
     return regno_alignment;
-  else if (known_eq (LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo), 1U))
+  else
     {
       int estimated_vf = vect_vf_for_cost (loop_vinfo);
       int estimated_lmul = estimated_vf * GET_MODE_BITSIZE (mode).to_constant ()
@@ -636,25 +634,6 @@ compute_estimated_lmul (loop_vec_info loop_vinfo, machine_mode mode)
       else
        return estimated_lmul;
     }
-  else
-    {
-      /* Estimate the VLA SLP LMUL.  */
-      if (regno_alignment > RVV_M1)
-       return regno_alignment;
-      else if (mode != QImode
-              || LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo).is_constant ())
-       {
-         int ratio;
-         if (can_div_trunc_p (BYTES_PER_RISCV_VECTOR,
-                              GET_MODE_SIZE (loop_vinfo->vector_mode), &ratio))
-           {
-             if (ratio == 1)
-               return RVV_M4;
-             else if (ratio == 2)
-               return RVV_M2;
-           }
-       }
-    }
   return 0;
 }
 
index 85e3021f1c2b671aa4b026bd5dc6646c8d792357..b5a7f180228a27b7a887af48ba1f891f3ae22db6 100644 (file)
@@ -45,4 +45,4 @@ void foo2 (int64_t *__restrict a,
 /* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */
 /* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */
 /* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 3 "vect" } } */
index 793d16418bf17cefee391a912436d763ab77fb70..56234580fa82f738741c3dc60bd742c0f129b803 100644 (file)
@@ -14,6 +14,5 @@ foo (int64_t *__restrict a, int64_t init, int n)
 /* { dg-final { scan-assembler {e64,m8} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */
-/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */
 /* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */
 /* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */