public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2656] Check another epilog variable peeling case in vectorizable_nonlinear_induction.
@ 2022-09-14  7:46 hongtao Liu
  0 siblings, 0 replies; only message in thread
From: hongtao Liu @ 2022-09-14  7:46 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:93b09bf3246f413b8e469ebfd8ce43947c0073a6

commit r13-2656-g93b09bf3246f413b8e469ebfd8ce43947c0073a6
Author: liuhongt <hongtao.liu@intel.com>
Date:   Tue Sep 13 13:25:24 2022 +0800

    Check another epilog variable peeling case in vectorizable_nonlinear_induction.
    
    in vectorizable_nonlinear_induction, r13-2503-gc13223b790bbc5 prevent variable peeling by
    only checking LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo). But when
    "!vect_use_loop_mask_for_alignment_p (loop_vinfo) &&
    LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0", vectorizer will
    still do variable peeling for epilog, and it hits gcc_assert in
    vect_peel_nonlinear_iv_init.
    
    gcc/ChangeLog:
    
            PR tree-optimization/106905
            * tree-vect-loop.cc (vectorizable_nonlinear_induction): Return
            false when !vect_use_loop_mask_for_alignment_p (loop_vinfo) &&
            LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/pr106905.c: New test.
            * gcc.target/ia64/pr106905.c: New test.

Diff:
---
 gcc/testsuite/gcc.target/i386/pr106905.c | 14 ++++++++++++++
 gcc/testsuite/gcc.target/ia64/pr106905.c | 20 ++++++++++++++++++++
 gcc/tree-vect-loop.cc                    |  6 ++++--
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/pr106905.c b/gcc/testsuite/gcc.target/i386/pr106905.c
new file mode 100644
index 00000000000..a190a1c84e6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr106905.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-march=silvermont -O2 -fvect-cost-model=dynamic" } */
+
+void
+foo_mul_peel (int *a, int b)
+{
+  int i;
+
+  for (i = 0; i < 7; ++i)
+    {
+      b *= 2;
+      a[i] = b;
+    }
+}
diff --git a/gcc/testsuite/gcc.target/ia64/pr106905.c b/gcc/testsuite/gcc.target/ia64/pr106905.c
new file mode 100644
index 00000000000..1b9656e1203
--- /dev/null
+++ b/gcc/testsuite/gcc.target/ia64/pr106905.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -O3 -fPIC" } */
+long ZDICT_fillNoise_p, ZDICT_trainFromBuffer_legacy_result;
+unsigned ZDICT_fillNoise_acc;
+int ZDICT_totalSampleSize_nbFiles;
+static void ZDICT_fillNoise(void *buffer, long length) {
+  unsigned prime2 = 9;
+  for (ZDICT_fillNoise_p = 0; ZDICT_fillNoise_p < length; ZDICT_fillNoise_p++)
+    ZDICT_fillNoise_acc *= ((char *)buffer)[ZDICT_fillNoise_p] = prime2;
+}
+long ZDICT_trainFromBuffer_legacy() {
+  void *newBuff;
+  long total = 0;
+  for (; ZDICT_totalSampleSize_nbFiles;)
+    total += 0;
+  long sBuffSize = total;
+  newBuff = 0;
+  ZDICT_fillNoise(newBuff + sBuffSize, 32);
+  return ZDICT_trainFromBuffer_legacy_result;
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 8f88f1755be..9c434b66c5b 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -8646,8 +8646,10 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo,
   /* Also doens't support peel for neg when niter is variable.
      ??? generate something like niter_expr & 1 ? init_expr : -init_expr?  */
   niters_skip = LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo);
-  if (niters_skip != NULL_TREE
-      && TREE_CODE (niters_skip) != INTEGER_CST)
+  if ((niters_skip != NULL_TREE
+       && TREE_CODE (niters_skip) != INTEGER_CST)
+      || (!vect_use_loop_mask_for_alignment_p (loop_vinfo)
+	  && LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0))
     {
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-14  7:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14  7:46 [gcc r13-2656] Check another epilog variable peeling case in vectorizable_nonlinear_induction hongtao Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).