public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joel Hutton <Joel.Hutton@arm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Richard Sandiford <Richard.Sandiford@arm.com>,
	Richard Biener <rguenther@suse.de>
Subject: pr103523: Check for PLUS/MINUS support
Date: Fri, 10 Dec 2021 10:02:49 +0000	[thread overview]
Message-ID: <DB9PR08MB66030FB1C55990D025E62326F5719@DB9PR08MB6603.eurprd08.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 634 bytes --]

Hi all,

This is to address pr103523.

bootstrapped and regression tested on aarch64.

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/PR103523
	* tree-vect-loop.c (vectorizable_induction): Check for
    PLUS_EXPR/MINUS_EXPR support.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: rb15140.patch --]
[-- Type: text/x-patch; name="rb15140.patch", Size: 1778 bytes --]

diff --git a/gcc/testsuite/gcc.target/aarch64/pr103523.c b/gcc/testsuite/gcc.target/aarch64/pr103523.c
new file mode 100644
index 0000000000000000000000000000000000000000..736e8936c5f6768bdf098ddc37b2c21ab74ee0df
--- /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 7f544ba1fd5198dd32cda05e62382ab2e1e9bb50..f700d5e7ac2c05402407a46113320f79359906fa 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -8065,6 +8065,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;
@@ -8124,10 +8133,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);

             reply	other threads:[~2021-12-10 10:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 10:02 Joel Hutton [this message]
2021-12-10 10:22 ` Richard Sandiford
2021-12-10 13:24   ` Joel Hutton
2021-12-10 18:33     ` Richard Sandiford
2021-12-13 14:27     ` GCC 11 backport does not build (no "directly_supported_p") - was: " Tobias Burnus
2021-12-13 14:47       ` Richard Biener
2021-12-13 15:02         ` Joel Hutton
2021-12-14  9:37           ` Joel Hutton
2021-12-14  9:53             ` Jakub Jelinek
2021-12-14 10:46               ` Joel Hutton
2021-12-14 10:57                 ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB9PR08MB66030FB1C55990D025E62326F5719@DB9PR08MB6603.eurprd08.prod.outlook.com \
    --to=joel.hutton@arm.com \
    --cc=Richard.Sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).