public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/112331] Fail vectorization after loop interchange
Date: Thu, 02 Nov 2023 10:00:48 +0000	[thread overview]
Message-ID: <bug-112331-4-NtWTkbJvXZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112331-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|middle-end: Fail            |Fail vectorization after
                   |vectorization               |loop interchange
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Well, the "issue" is that we are performing loop interchange on this benchmark
loop and the vectorizer doesn't like the zero-step in the then innermost loop.

It's not a practical example, nobody would do such outer loop in practice.

There's a missed optimization in that we fail to elide the then inner loop.

The solution is to insert a use of 'a' after the inner loop, like TSVC
benchmarks usually have:

real_t s111(struct args_t * func_args)
{
//    linear dependence testing
//    no dependence - vectorizable

    initialise_arrays(__func__);

    for (int nl = 0; nl < 2*iterations; nl++) {
        for (int i = 1; i < LEN_1D; i += 2) {
            a[i] = a[i - 1] + b[i];
        }
        dummy(a, b, c, d, e, aa, bb, cc, 0.);
    }

    return calc_checksum(__func__);
}

the it just works(TM).

WONTFIX (in the vectorizer).  In "theory" the interchanged loop could be
vectorized by outer loop vectorization.  But as said, IMHO a waste of time
to cheat badly written benchmarks.

  parent reply	other threads:[~2023-11-02 10:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01  9:20 [Bug c/112331] New: middle-end: Fail vectorization juzhe.zhong at rivai dot ai
2023-11-01  9:24 ` [Bug c/112331] " juzhe.zhong at rivai dot ai
2023-11-02  7:42 ` [Bug tree-optimization/112331] " juzhe.zhong at rivai dot ai
2023-11-02 10:00 ` rguenth at gcc dot gnu.org [this message]
2023-11-02 10:14 ` [Bug tree-optimization/112331] Fail vectorization after loop interchange juzhe.zhong at rivai dot ai
2023-11-02 10:48 ` rguenth 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-112331-4-NtWTkbJvXZ@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).