public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tnfchris at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/113808] [14 Regression] FAIL: libgomp.fortran/non-rectangular-loop-1.f90 since r14-8768
Date: Thu, 08 Feb 2024 04:28:38 +0000	[thread overview]
Message-ID: <bug-113808-4-JBEEOKZdhH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113808-4@http.gcc.gnu.org/bugzilla/>

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

Tamar Christina <tnfchris at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |tnfchris at gcc dot gnu.org

--- Comment #9 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #6)
> With the following I don't see things going wrong, but we end up with the
> loop
> having the STOP exit last instead and thus a PEELED case.

If it's not a PEELED case than the code is wrong indeed.

  _100 = BIT_FIELD_REF <vect_vec_iv_.27_99, 32, 0>;
  k.4_43 = _100;

is wrong since for a normal case the primary exit needs to do a last reduction
rather than a first.

  _109 = BIT_FIELD_REF <vect__19.29_108, 32, 96>;
  _48 = _109;
  _100 = BIT_FIELD_REF <vect_vec_iv_.27_99, 32, 0>;
  k.4_43 = _100;

these two reduction orders should never be different.

The bug seems to be in vectorizable_live_operations where we determine if the
index needs to be a first or last reduction.

There's a boolean there

restart_loop = restart_loop || !main_exit_edge;

and we initially set it to

bool restart_loop = LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo);

outside the USE/DEF loop.

The problem is this depends on seeing the uses for the LOOP_VINFO_IV_EXIT
before seeing that of the early exits.

The code goes wrong because we see the early exit first and then see the main
exit, but once true the boolean can't become false again.

it's a silly bug, the boolean shouldn't be cached between loop iters.

quick hack:

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 190df9ec774..109a7e16abb 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -10966,7 +10966,7 @@ vectorizable_live_operation (vec_info *vinfo,
stmt_vec_info stmt_info,
              /* For early exit where the exit is not in the BB that leads
                 to the latch then we're restarting the iteration in the
                 scalar loop.  So get the first live value.  */
-             restart_loop = restart_loop || !main_exit_edge;
+             restart_loop = !main_exit_edge;
              if (restart_loop
                  && STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def)
                {

works but will revisit this and fix properly now.

Thanks for the reduction.

  parent reply	other threads:[~2024-02-08  4:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-07 12:47 [Bug tree-optimization/113808] New: [14 Regression] FAIL: libgomp.fortran/non-rectangular-loop-1.f90 rguenth at gcc dot gnu.org
2024-02-07 13:28 ` [Bug tree-optimization/113808] " rguenth at gcc dot gnu.org
2024-02-07 13:37 ` tnfchris at gcc dot gnu.org
2024-02-07 13:39 ` [Bug tree-optimization/113808] [14 Regression] FAIL: libgomp.fortran/non-rectangular-loop-1.f90 since r14-8768 jakub at gcc dot gnu.org
2024-02-07 13:48 ` rguenth at gcc dot gnu.org
2024-02-07 13:53 ` rguenth at gcc dot gnu.org
2024-02-07 14:09 ` rguenth at gcc dot gnu.org
2024-02-07 14:20 ` jakub at gcc dot gnu.org
2024-02-07 14:20 ` jakub at gcc dot gnu.org
2024-02-07 14:25 ` rguenth at gcc dot gnu.org
2024-02-08  4:28 ` tnfchris at gcc dot gnu.org [this message]
2024-02-08 10:44 ` cvs-commit at gcc dot gnu.org
2024-02-08 10:45 ` tnfchris at gcc dot gnu.org
2024-02-08 11:11 ` cvs-commit 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-113808-4-JBEEOKZdhH@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).