public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "law at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/106240] New: [13 Regression] Recent change causes missed vectorization opportunity on mips
Date: Sat, 09 Jul 2022 03:45:50 +0000	[thread overview]
Message-ID: <bug-106240-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106240

            Bug ID: 106240
           Summary: [13 Regression] Recent change causes missed
                    vectorization opportunity on mips
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: law at gcc dot gnu.org
  Target Milestone: ---

This can be see on the mipsisa32r2-linux-gnu target with a cross compiler.

Starting a couple months ago these tests started failing on
mipsisa32r2-linux-gnu:

Tests that now fail, but worked before (24 tests):

gcc.target/mips/mips-ps-5.c   -O1   scan-assembler \tadd\\.ps\t
gcc.target/mips/mips-ps-5.c   -O1   scan-assembler \tc\\.eq\\.ps\t
gcc.target/mips/mips-ps-5.c   -O1   scan-assembler \tmov[tf]\\.ps\t
gcc.target/mips/mips-ps-5.c   -O2   scan-assembler \tadd\\.ps\t
gcc.target/mips/mips-ps-5.c   -O2   scan-assembler \tc\\.eq\\.ps\t
gcc.target/mips/mips-ps-5.c   -O2   scan-assembler \tmov[tf]\\.ps\t
gcc.target/mips/mips-ps-5.c   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions   scan-assembler \tadd\\.ps\t
gcc.target/mips/mips-ps-5.c   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions   scan-assembler \tc\\.eq\\.ps\t
gcc.target/mips/mips-ps-5.c   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions   scan-assembler \tmov[tf]\\.ps\t
gcc.target/mips/mips-ps-5.c   -O3 -g   scan-assembler \tadd\\.ps\t
gcc.target/mips/mips-ps-5.c   -O3 -g   scan-assembler \tc\\.eq\\.ps\t
gcc.target/mips/mips-ps-5.c   -O3 -g   scan-assembler \tmov[tf]\\.ps\t
gcc.target/mips/mips-ps-7.c   -O1   scan-assembler \tadd\\.ps\t
gcc.target/mips/mips-ps-7.c   -O1   scan-assembler \tc\\.eq\\.ps\t
gcc.target/mips/mips-ps-7.c   -O1   scan-assembler \tmov[tf]\\.ps\t
gcc.target/mips/mips-ps-7.c   -O2   scan-assembler \tadd\\.ps\t
gcc.target/mips/mips-ps-7.c   -O2   scan-assembler \tc\\.eq\\.ps\t
gcc.target/mips/mips-ps-7.c   -O2   scan-assembler \tmov[tf]\\.ps\t
gcc.target/mips/mips-ps-7.c   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions   scan-assembler \tadd\\.ps\t
gcc.target/mips/mips-ps-7.c   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions   scan-assembler \tc\\.eq\\.ps\t
gcc.target/mips/mips-ps-7.c   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions   scan-assembler \tmov[tf]\\.ps\t
gcc.target/mips/mips-ps-7.c   -O3 -g   scan-assembler \tadd\\.ps\t
gcc.target/mips/mips-ps-7.c   -O3 -g   scan-assembler \tc\\.eq\\.ps\t
gcc.target/mips/mips-ps-7.c   -O3 -g   scan-assembler \tmov[tf]\\.ps\t

This change is the trigger:
commit 68e0063397ba820e71adc220b2da0581dce29ffa
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Apr 11 13:36:53 2022 +0200

    Force the selection operand of a GIMPLE COND_EXPR to be a register

    This goes away with the selection operand allowed to be a GENERIC
    tcc_comparison tree.  It keeps those for vectorizer pattern recog,
    those are short lived and removing this instance is a bigger task.

    The patch doesn't yet remove dead code and functionality, that's
    left for a followup.  Instead the patch makes sure to produce
    valid GIMPLE IL and continue to optimize COND_EXPRs where the
    previous IL allowed and the new IL showed regressions in the testsuite.

[ ... ]


Basically before this change we were able to vectorize the loop and after that
change we no longer vectorize the loop.

Testcase:

/* { dg-do compile } */
/* { dg-options "-mpaired-single -mgp64 -ftree-vectorize forbid_cpu=octeon.*" }
*/
/* { dg-skip-if "requires vectorization" { *-*-* } { "-O0" "-Os" } { "" } } */

extern float a[] __attribute__ ((aligned (8)));
extern float b[] __attribute__ ((aligned (8)));
extern float c[] __attribute__ ((aligned (8)));

NOMIPS16 void
foo (void)
{
  int i;
  for (i = 0; i < 16; i++)
    a[i] = b[i] == c[i] + 1 ? b[i] : c[i];
}

/* { dg-final { scan-assembler "\tadd\\.ps\t" } } */
/* { dg-final { scan-assembler "\tc\\.eq\\.ps\t" } } */
/* { dg-final { scan-assembler "\tmov\[tf\]\\.ps\t" } } */


Compilation line:

/home/jlaw/test/obj/mipsisa32r2-linux-gnu/obj/gcc/gcc/xgcc
-B/home/jlaw/test/obj/mipsisa32r2-linux-gnu/obj/gcc/gcc/
/home/jlaw/test/gcc/gcc/testsuite/gcc.target/mips/mips-ps-5.c
-fdiagnostics-plain-output -O2 -DNOMIPS16="__attribute__((nomips16))"
-DNOMICROMIPS="__attribute__((nomicromips))"
-DNOCOMPRESSION="__attribute__((nocompression))" -mabi=o64 -mips64r2
-mhard-float -mdouble-float -mfp64 -mgp64 -mlong32 -mpaired-single -modd-spreg
-ftree-vectorize -fno-ident -S -o mips-ps-5.s -fdump-tree-all-details


As one would expect this patch changes the form of the COND_EXPRs and
ultimately we're unable to vectorize as a result.  I haven't dug any deeper
than that.

             reply	other threads:[~2022-07-09  3:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-09  3:45 law at gcc dot gnu.org [this message]
2022-07-09  6:00 ` [Bug tree-optimization/106240] " pinskia at gcc dot gnu.org
2022-07-11 12:41 ` [Bug target/106240] [13 Regression] missed vectorization opportunity (cond move) on mips since r13-707-g68e0063397ba82 rguenth at gcc dot gnu.org
2022-07-11 20:27 ` law at gcc dot gnu.org
2022-07-11 20:36 ` pinskia at gcc dot gnu.org
2022-07-12  6:04 ` rguenth at gcc dot gnu.org
2023-04-08 14:43 ` law at gcc dot gnu.org
2023-04-26  6:56 ` [Bug target/106240] [13/14 " rguenth at gcc dot gnu.org
2023-07-27  9:23 ` rguenth at gcc dot gnu.org
2024-05-21  9:11 ` [Bug target/106240] [13/14/15 " jakub at gcc dot gnu.org

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=bug-106240-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).