public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9380] pr103523: Check for PLUS/MINUS support
@ 2021-12-13 14:21 Joel Hutton
  0 siblings, 0 replies; only message in thread
From: Joel Hutton @ 2021-12-13 14:21 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f2cc8d059df8aea1b811a4a68512d137f4e83bd5

commit r11-9380-gf2cc8d059df8aea1b811a4a68512d137f4e83bd5
Author: Joel Hutton <joel.hutton@arm.com>
Date:   Fri Dec 10 10:26:42 2021 +0000

    pr103523: Check for PLUS/MINUS support
    
    Check for PLUS_EXPR/MINUS_EXPR support in vectorizable_induction.
    PR103523 is an ICE on valid code:
    
    void d(float *a, float b, int c) {
        float e;
        for (; c; c--, e += b)
          a[c] = e;
    }
    
    This is due to not checking for PLUS_EXPR support, which is missing in
    VNx2sf mode. This causes an ICE at expand time. This patch adds a check
    for support in vectorizable_induction.
    
    gcc/ChangeLog:
    
            PR tree-optimization/103523
            * tree-vect-loop.c (vectorizable_induction): Check for
            PLUS_EXPR/MINUS_EXPR support.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/pr103523.c: New test.

Diff:
---
 gcc/testsuite/gcc.target/aarch64/pr103523.c |  8 ++++++++
 gcc/tree-vect-loop.c                        | 13 +++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/pr103523.c b/gcc/testsuite/gcc.target/aarch64/pr103523.c
new file mode 100644
index 00000000000..736e8936c5f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr103523.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-march=armv8-a+sve -mtune=neoverse-v1 -Ofast" } */
+
+void d(float *a, float b, int c) {
+    float e;
+    for (; c; c--, e += b)
+      a[c] = e;
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index e871df9d1a0..54320681119 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -7992,6 +7992,15 @@ vectorizable_induction (loop_vec_info loop_vinfo,
       return false;
     }
 
+  step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_info);
+  gcc_assert (step_expr != NULL_TREE);
+  tree step_vectype = get_same_sized_vectype (TREE_TYPE (step_expr), vectype);
+
+  /* Check for backend support of PLUS/MINUS_EXPR. */
+  if (!directly_supported_p (PLUS_EXPR, step_vectype)
+      || !directly_supported_p (MINUS_EXPR, step_vectype))
+    return false;
+
   if (!vec_stmt) /* transformation not required.  */
     {
       unsigned inside_cost = 0, prologue_cost = 0;
@@ -8051,10 +8060,6 @@ vectorizable_induction (loop_vec_info loop_vinfo,
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location, "transform induction phi.\n");
 
-  step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_info);
-  gcc_assert (step_expr != NULL_TREE);
-  tree step_vectype = get_same_sized_vectype (TREE_TYPE (step_expr), vectype);
-
   pe = loop_preheader_edge (iv_loop);
   /* Find the first insertion point in the BB.  */
   basic_block bb = gimple_bb (phi);


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

only message in thread, other threads:[~2021-12-13 14:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-13 14:21 [gcc r11-9380] pr103523: Check for PLUS/MINUS support Joel Hutton

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).