]> gcc.gnu.org Git - gcc.git/commitdiff
RISC-V: Some minior tweak on dynamic LMUL cost model
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Tue, 26 Dec 2023 08:42:27 +0000 (16:42 +0800)
committerPan Li <pan2.li@intel.com>
Tue, 26 Dec 2023 09:15:41 +0000 (17:15 +0800)
Tweak some codes of dynamic LMUL cost model to make computation more predictable and accurate.

Tested on both RV32 and RV64 no regression.

Committed.

PR target/113112

gcc/ChangeLog:

* config/riscv/riscv-vector-costs.cc (compute_estimated_lmul): Tweak LMUL estimation.
(has_unexpected_spills_p): Ditto.
(costs::record_potential_unexpected_spills): Ditto.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-1.c: Add more checks.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-2.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-3.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-4.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-5.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-6.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-7.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-1.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-2.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-3.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-4.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-5.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-1.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-2.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-3.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-5.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-6.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-7.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-8.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-1.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-10.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-11.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-2.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-3.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-4.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-5.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-6.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-7.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-8.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-9.c: Ditto.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-12.c: New test.
* gcc.dg/vect/costmodel/riscv/rvv/pr113112-2.c: New test.

33 files changed:
gcc/config/riscv/riscv-vector-costs.cc
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-1.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-2.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-3.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-4.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-5.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-6.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul1-7.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-1.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-2.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-3.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-4.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-5.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-1.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-2.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-3.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-5.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-6.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-7.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-8.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-1.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-10.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-11.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-12.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-2.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-3.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-4.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-5.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-6.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-7.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-8.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-9.c
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr113112-2.c [new file with mode: 0644]

index 7b837b08f9ecf5f85191bceb14e4d7dfe30ff8f7..74b8e86a5e11b5fa38cdbaffa7ba16689e531b9f 100644 (file)
@@ -394,21 +394,32 @@ compute_estimated_lmul (loop_vec_info loop_vinfo, machine_mode mode)
 {
   gcc_assert (GET_MODE_BITSIZE (mode).is_constant ());
   int regno_alignment = riscv_get_v_regno_alignment (loop_vinfo->vector_mode);
-  if (known_eq (LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo), 1U))
+  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)
+          || LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo).is_constant ())
     {
       int estimated_vf = vect_vf_for_cost (loop_vinfo);
       return estimated_vf * GET_MODE_BITSIZE (mode).to_constant ()
             / TARGET_MIN_VLEN;
     }
-  else if (regno_alignment > 1)
-    return regno_alignment;
   else
     {
-      int ratio;
-      if (can_div_trunc_p (BYTES_PER_RISCV_VECTOR,
-                          LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo),
-                          &ratio))
-       return TARGET_MAX_LMUL / ratio;
+      /* Estimate the VLA SLP LMUL.  */
+      if (regno_alignment > RVV_M1)
+       return regno_alignment;
+      else if (mode != QImode)
+       {
+         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;
 }
@@ -540,7 +551,10 @@ update_local_live_ranges (
          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 (non_contiguous_memory_access_p (stmt_info))
+         if (non_contiguous_memory_access_p (stmt_info)
+             /* LOAD_LANES/STORE_LANES doesn't need a perm indice.  */
+             && STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info)
+                  != VMAT_LOAD_STORE_LANES)
            {
              /* For non-adjacent load/store STMT, we will potentially
                 convert it into:
@@ -578,9 +592,6 @@ update_local_live_ranges (
 static bool
 has_unexpected_spills_p (loop_vec_info loop_vinfo)
 {
-  /* We don't apply dynamic LMUL cost model on VLS modes.  */
-  if (!riscv_v_ext_vector_mode_p (loop_vinfo->vector_mode))
-    return false;
   /* Compute local program points.
      It's a fast and effective computation.  */
   hash_map<basic_block, vec<stmt_point>> program_points_per_bb;
@@ -682,7 +693,12 @@ costs::analyze_loop_vinfo (loop_vec_info loop_vinfo)
 void
 costs::record_potential_unexpected_spills (loop_vec_info loop_vinfo)
 {
-  if (riscv_autovec_lmul == RVV_DYNAMIC)
+  /* We only want to apply the heuristic if LOOP_VINFO is being
+     vectorized for VLA and known NITERS VLS loop.  */
+  if (riscv_autovec_lmul == RVV_DYNAMIC
+      && (m_cost_type == VLA_VECTOR_COST
+         || (m_cost_type == VLS_VECTOR_COST
+             && LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))))
     {
       bool post_dom_available_p = dom_info_available_p (CDI_POST_DOMINATORS);
       if (!post_dom_available_p)
index 76c47dde93618871c36971c71e9bf8a8a09539ef..f481c8094c9a52d149dd3dee96e3c612f1b93e88 100644 (file)
@@ -86,3 +86,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b,    int32_t *__restrict c,
 /* { dg-final { scan-assembler {e32,m1} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "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" } } */
index f2ca677f1b0a6b8f05f59817b29cc7bc0b62b9c0..e044c65e7f259a8cdcc781551d768cb34a1d2a6d 100644 (file)
@@ -58,3 +58,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b,    int32_t *__restrict c,
 /* { dg-final { scan-assembler {e32,m1} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "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" } } */
index 49553a39cb9dcbc2bad7ca935f3c68632921f286..212788a93c3fd7e0f491849d1403c817595b9d5d 100644 (file)
@@ -86,3 +86,6 @@ foo (int8_t *__restrict a, int8_t *__restrict b,    int8_t *__restrict c,
 /* { dg-final { scan-assembler {e8,m1} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "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" } } */
index 6afbbf87683ad9aee1008ff617cb8d5ba105db86..2e2ff9dc74ac33334cc475bb66ffa4126d880433 100644 (file)
@@ -116,3 +116,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b,    int32_t *__restrict c,
 /* { dg-final { scan-assembler {e32,m1} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "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" } } */
index 9037187dd30409af2e362ebcfa6d9f12de39d761..80eb38c9986f4363cb32bd3715c82e7825e9b8ec 100644 (file)
@@ -144,3 +144,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b,    int32_t *__restrict c,
 /* { dg-final { scan-assembler {e32,m1} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "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" } } */
index cabb5f54a93d52a7c53f80e72c408baae16657a6..3dd594e3f6eab8f117a27f318ebb0300d6f9b623 100644 (file)
@@ -145,3 +145,6 @@ foo (int8_t *__restrict a, int8_t *__restrict b,    int8_t *__restrict c,
 /* { dg-final { scan-assembler {e8,m1} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "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" } } */
index b3902e2d4b3d701ba59d0f9e3ec2f883d2d9626e..87b943cca4c9633f51bd8735b7759fb0fbfff0f2 100644 (file)
@@ -43,3 +43,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c,
 /* { dg-final { scan-assembler {e32,m1} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "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" } } */
index 2145cb86c438ba43cfcd0d1d9e5a0de6d083906d..0079aa02a85383224b9a79488d010b97e04afd46 100644 (file)
@@ -46,3 +46,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b,    int32_t *__restrict c,
 /* { dg-final { scan-assembler {e32,m2} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "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" } } */
index a5bf4b67a924c2d7911fb133aa4f675f76c937a1..d8a0e66a65e7fc223d36434baabec2bb9f277dc9 100644 (file)
@@ -46,3 +46,6 @@ foo (int8_t *__restrict a, int8_t *__restrict b,    int8_t *__restrict c,
 /* { dg-final { scan-assembler {e8,m2} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "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" } } */
index 2145cb86c438ba43cfcd0d1d9e5a0de6d083906d..0079aa02a85383224b9a79488d010b97e04afd46 100644 (file)
@@ -46,3 +46,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b,    int32_t *__restrict c,
 /* { dg-final { scan-assembler {e32,m2} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "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" } } */
index 6ed9eea5aa0fc91f8ef12df31e4255493d3869d6..23269196b85621508f812bbad856ff33ec3ff34d 100644 (file)
@@ -44,3 +44,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c,
 /* { dg-final { scan-assembler {e32,m2} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "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" } } */
index 72c1cb49e7c2b59043f4cb3007dcffc305f54813..2ef88a307bce817d934bb700973d699e35ca2183 100644 (file)
@@ -47,3 +47,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c,
 /* { dg-final { scan-assembler {e8,m8} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "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" } } */
index a87ff6744f2ab99671a26243e58b9900390e33bb..08dc7ca92dd575ec2ce8e01cb004011a4611d602 100644 (file)
@@ -30,3 +30,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c,
 /* { dg-final { scan-assembler {e32,m4} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "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" } } */
index 3d7dc92db9b213b70e32bd5042b1b9d612ec7907..b9a9229ed9f82e9feb5d36b0622752a0ad2dd5ce 100644 (file)
@@ -30,3 +30,6 @@ foo (int8_t *__restrict a, int8_t *__restrict b, int8_t *__restrict c,
 /* { dg-final { scan-assembler {e8,m4} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "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" } } */
index 09eacca1a2cc1524787d19fb292d209fd9172b77..cd476cb80ca0850add66164e27cc05d3ec26c68a 100644 (file)
@@ -42,3 +42,6 @@ void foo2 (int64_t *__restrict a,
 /* { dg-final { scan-assembler {e64,m4} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "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" } } */
index 88f58446abaf69706c5e5db3a238fcc16642cbfe..d48a37666aeb547447d7d1b8948d685400d69c1a 100644 (file)
@@ -42,3 +42,6 @@ void foo2 (int16_t *__restrict a,
 /* { dg-final { scan-assembler {e16,m2} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "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" } } */
index aa4f4b170f0934527ed8b0a159abf95804f9e64c..d2766f5984c11fd869c2ab01cc42596d33e2f955 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fselective-scheduling -fdump-tree-vect-details" } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=scalable -fselective-scheduling -fdump-tree-vect-details" } */
 
 #include <stdint-gcc.h>
 
@@ -23,3 +23,6 @@ foo (uint8_t *restrict a, uint8_t *restrict b, int n)
 /* { dg-final { scan-assembler-times {csrr} 1 } } */
 /* Since we don't support VLA SLP for LMUL = 8, dynamic LMUL cost model start from LMUL = 4.  */
 /* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */
+/* { dg-final { scan-tree-dump-not "Maximum lmul = 8" "vect" } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */
index 0606320f50ad505f44a8746f18a3fa6de049786a..45bceaac0eb8348b3a2405f0b8a39c4550296459 100644 (file)
@@ -42,3 +42,6 @@ void foo2 (int8_t *__restrict a,
 /* { dg-final { scan-assembler {e64,m4} } } */
 /* { dg-final { scan-assembler-not {csrr} } } */
 /* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "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" } } */
index 717cce973040108838456a4f8857c006ab3774ee..362c49f1411c45d30ed1ffe94a8bee793c00f0d1 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fselective-scheduling -fdump-tree-vect-details" } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=scalable -fselective-scheduling -fdump-tree-vect-details" } */
 
 #include <stdint-gcc.h>
 
@@ -32,3 +32,6 @@ foo (uint8_t *restrict a, uint8_t *restrict b, int n)
 /* { dg-final { scan-assembler-times {csrr} 1 } } */
 /* Since we don't support VLA SLP for LMUL = 8, dynamic LMUL cost model start from LMUL = 4.  */
 /* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */
+/* { dg-final { scan-tree-dump-not "Maximum lmul = 8" "vect" } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */
index 7eda6b0f12319c9abc6e3ccb051c009d529fe9a7..702a3b74f9a32776b5d568e1817137777ff392f5 100644 (file)
@@ -13,3 +13,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b, int n)
 /* { dg-final { scan-assembler {e32,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" } } */
index b0f8f8f0dacd30040bea18d3de4a162308de7381..95b0600a9d7f7141b12d544576bdd186d3c7bb71 100644 (file)
@@ -17,3 +17,6 @@ foo (int *x, int n, int res)
 /* { dg-final { scan-assembler {e32,m8} } } */
 /* { dg-final { scan-assembler-times {csrr} 1 } } */
 /* { 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" } } */
index 3b37c8928cc924d272e8632def621cf76c863133..83df2bc46e580fc87f1e0fdfcce20bd558ac86bc 100644 (file)
@@ -42,3 +42,6 @@ void foo2 (int64_t *__restrict a,
 /* { 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" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-12.c b/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-12.c
new file mode 100644 (file)
index 0000000..d0f3542
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=scalable -fselective-scheduling -fdump-tree-vect-details" } */
+
+void
+foo (int *restrict a, int *restrict b, int n)
+{
+  for (int i = 0; i < n; ++i)
+    {
+      a[i * 8] = b[i * 8 + 7] + 1;
+      a[i * 8 + 1] = b[i * 8 + 6] + 2;
+      a[i * 8 + 2] = b[i * 8 + 5] + 3;
+      a[i * 8 + 3] = b[i * 8 + 4] + 4;
+      a[i * 8 + 4] = b[i * 8 + 3] + 5;
+      a[i * 8 + 5] = b[i * 8 + 2] + 6;
+      a[i * 8 + 6] = b[i * 8 + 1] + 7;
+      a[i * 8 + 7] = b[i * 8 + 0] + 8;
+    }
+}
+
+/* { dg-final { scan-assembler {e32,m8} } } */
+/* { dg-final { scan-assembler-times {csrr} 1 } } */
+/* { 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" } } */
index 802a4dddfaf97ca228fab003f732fdb658e4770b..c3d0d5d574c2352764131a4a464b61654c527f96 100644 (file)
@@ -13,3 +13,6 @@ foo (int32_t *__restrict a, int16_t *__restrict b, int n)
 /* { dg-final { scan-assembler {e16,m4} } } */
 /* { 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" } } */
index b55863de54c07f92ab3b6ca0ac28d8097b8a152a..a575427f8cd107749da502b2e6a603ff1250c480 100644 (file)
@@ -13,3 +13,6 @@ foo (int8_t *__restrict a, int8_t *__restrict b, int n)
 /* { dg-final { scan-assembler {e8,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" } } */
index faa4428eb26b432d94676dbbb982de65f772f43a..b55bcad6a2754fee7771bf366efffbb7eb798db3 100644 (file)
@@ -14,3 +14,6 @@ foo (size_t *__restrict a, size_t *__restrict b, 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" 2 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */
index 944c2395163e256477b02967039801be3f0ed491..307dd69e2c48808a880b8884c6922540ee355ce4 100644 (file)
@@ -20,3 +20,6 @@ foo (int8_t *__restrict a, int8_t *__restrict b, int n)
 /* { dg-final { scan-assembler {e8,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" } } */
index 2aeb7dfa73f12fd5ebcf3c3286ecff1b2ee1924d..9a7eb421d8816e1a2c6e3616df16751b12a876a0 100644 (file)
@@ -18,3 +18,6 @@ foo (int8_t *__restrict a, int8_t *__restrict b, int8_t *__restrict a2,
 /* { dg-final { scan-assembler {e8,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" } } */
index 37757c81d794f1b04a9b479066ae2a7cef2d6a9a..103d22b23afd8c566e3b2e15475b4d4b037e6057 100644 (file)
@@ -18,3 +18,6 @@ foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict a2,
 /* { dg-final { scan-assembler {e32,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" } } */
index 90ccbf15be3192cf790eac178cc97d816292afe4..0255bdf8cc6d76b538853ce204725b4348d30d08 100644 (file)
@@ -14,3 +14,6 @@ foo (int8_t *__restrict a, int8_t init, int n)
 /* { dg-final { scan-assembler {e8,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" } } */
index 7ad5799c10f637232ec6c18972f9a7653fb65015..e6cc1ad83e615441720ec35ca9217672bd032065 100644 (file)
@@ -14,3 +14,6 @@ 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" 2 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr113112-2.c b/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr113112-2.c
new file mode 100644 (file)
index 0000000..bc4f40d
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=fixed-vlmax -fdump-tree-vect-details" } */
+
+#define TYPE double
+#define N 200
+
+#include <complex.h>
+
+void addconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N],
+                 _Complex TYPE c[restrict N])
+{
+#if defined (UNROLL)
+#pragma GCC unroll 16
+#endif
+  for (int i=0; i < N; i++)
+    c[i] = ~a[i] + ~b[i];
+}
+
+/* { dg-final { scan-assembler {e64,m4} } } */
+/* { dg-final { scan-tree-dump-times "Maximum lmul = 4, At most 16 number of live V_REG" 1 "vect" } } */
This page took 0.09782 seconds and 5 git commands to generate.