From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1035) id 047F03858294; Fri, 23 Feb 2024 11:41:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 047F03858294 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708688465; bh=f4FJ8BMoZi9qcnrhGsEponXuGxStbhkaP+s+AXQfeEU=; h=From:To:Subject:Date:From; b=l6DqoIFfr51H8sNvp298an45Ods6UGZCjfbdJqpmkCn7Zul0+LJenjnE6gs4Ro2QR yrEXNZRfxvVfM0MVkneqZk7vGniS+TUhegwahuqa+9pXnj18lM686bahV4Qkskd71e 6tVcy26/DDxo5TIzIQ/LVJCPOZKK+xiABKVZ6fGA= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Earnshaw To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9152] arm: fix ICE with vectorized reciprocal division [PR108120] X-Act-Checkin: gcc X-Git-Author: Richard Earnshaw X-Git-Refname: refs/heads/master X-Git-Oldrev: 22121546e0315d25ee419d2389022e3974750885 X-Git-Newrev: 016c4eed368b80a97101f6156ed99e4c5474fbb7 Message-Id: <20240223114105.047F03858294@sourceware.org> Date: Fri, 23 Feb 2024 11:41:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:016c4eed368b80a97101f6156ed99e4c5474fbb7 commit r14-9152-g016c4eed368b80a97101f6156ed99e4c5474fbb7 Author: Richard Earnshaw 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 (div3): Rename from div3. Gate with ARM_HAVE_NEON__ARITH. gcc/testsuite: PR target/108120 * gcc.target/arm/neon-recip-div-1.c: New file. 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 17c90f436c6c..fa4a7aeda357 100644 --- a/gcc/config/arm/neon.md +++ b/gcc/config/arm/neon.md @@ -553,11 +553,11 @@ Enabled with -funsafe-math-optimizations -freciprocal-math and disabled for -Os since it increases code size . */ -(define_expand "div3" +(define_expand "div3" [(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__ARITH && !optimize_size && flag_reciprocal_math" { rtx rec = gen_reg_rtx (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\].*" } } */