public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Earnshaw <rearnsha@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-10174] arm: fix ICE with vectorized reciprocal division [PR108120]
Date: Fri, 23 Feb 2024 13:53:51 +0000 (GMT)	[thread overview]
Message-ID: <20240223135351.0D0D53858D1E@sourceware.org> (raw)

https://gcc.gnu.org/g:0de82d2c2ec0b7ed65a1122884feab40f90c0483

commit r12-10174-g0de82d2c2ec0b7ed65a1122884feab40f90c0483
Author: Richard Earnshaw <rearnsha@arm.com>
Date:   Thu Feb 22 16:47:20 2024 +0000

    arm: fix ICE with vectorized reciprocal division [PR108120]
    
    The expand pattern for reciprocal division was enabled for all math
    optimization modes, but the patterns it was generating were not
    enabled unless -funsafe-math-optimizations were enabled, this leads to
    an ICE when the pattern we generate cannot be recognized.
    
    Fixed by only enabling vector division when doing unsafe math.
    
    gcc:
    
            PR target/108120
            * config/arm/neon.md (div<VCVTF:mode>3): Rename from div<mode>3.
            Gate with ARM_HAVE_NEON_<MODE>_ARITH.
    
    gcc/testsuite:
            PR target/108120
            * gcc.target/arm/neon-recip-div-1.c: New file.
    
    (cherry picked from commit 016c4eed368b80a97101f6156ed99e4c5474fbb7)

Diff:
---
 gcc/config/arm/neon.md                          |  4 ++--
 gcc/testsuite/gcc.target/arm/neon-recip-div-1.c | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md
index 275bcc1435e2..b828fef9b71c 100644
--- a/gcc/config/arm/neon.md
+++ b/gcc/config/arm/neon.md
@@ -504,11 +504,11 @@
    Enabled with -funsafe-math-optimizations -freciprocal-math
    and disabled for -Os since it increases code size .  */
 
-(define_expand "div<mode>3"
+(define_expand "div<VCVTF:mode>3"
   [(set (match_operand:VCVTF 0 "s_register_operand")
         (div:VCVTF (match_operand:VCVTF 1 "s_register_operand")
 		  (match_operand:VCVTF 2 "s_register_operand")))]
-  "TARGET_NEON && !optimize_size
+  "ARM_HAVE_NEON_<MODE>_ARITH && !optimize_size
    && flag_reciprocal_math"
   {
     rtx rec = gen_reg_rtx (<MODE>mode);
diff --git a/gcc/testsuite/gcc.target/arm/neon-recip-div-1.c b/gcc/testsuite/gcc.target/arm/neon-recip-div-1.c
new file mode 100644
index 000000000000..e15c3ca5fe9d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/neon-recip-div-1.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options "-O3 -freciprocal-math -fno-unsafe-math-optimizations -save-temps" } */
+/* { dg-add-options arm_neon } */
+
+int *a;
+int n;
+void b() {
+  int c;
+  for (c = 0; c < 100000; c++)
+    a[c] = (float)c / n;
+}
+/* We should not ICE, or get a vectorized reciprocal instruction when unsafe
+   math optimizations are disabled.  */
+/* { dg-final { scan-assembler-not "vrecpe\\.f32\\t\[qd\].*" } } */
+/* { dg-final { scan-assembler-not "vrecps\\.f32\\t\[qd\].*" } } */

                 reply	other threads:[~2024-02-23 13:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240223135351.0D0D53858D1E@sourceware.org \
    --to=rearnsha@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).