public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "crazylht at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/110015] openjpeg is slower when built with gcc13 compared to clang16
Date: Wed, 01 Nov 2023 01:15:22 +0000	[thread overview]
Message-ID: <bug-110015-4-QB36VboRco@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110015-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Hongtao.liu <crazylht at gmail dot com> ---
169test.c:85:23: note:   vect_is_simple_use: operand max_38 = PHI <max_5(16),
max_40(43)>, type of def: unknown
170test.c:85:23: missed:   Unsupported pattern.
171test.c:62:24: missed:   not vectorized: unsupported use in stmt.
172test.c:85:23: missed:  unexpected pattern.
173test.c:85:23: note:  ***** Analysis  failed with vector mode V8SI
174test.c:85:23: note:  ***** The result for vector mode V32QI would be the
same
175test.c:85:23: missed: couldn't vectorize loop
176test.c:65:13: note: vectorized 0 loops in function.
177Removing basic block 5
178;; basic block 5, loop depth 2
179;;  pred:       16
180;;              43
181# max_38 = PHI <max_5(16), max_40(43)>
182# i_42 = PHI <i_29(16), 0(43)>
183# datap_44 = PHI <datap_30(16), datap_46(43)>
184tmp_24 = *datap_44;
185_35 = tmp_24 < 0;
186_56 = (unsigned int) tmp_24;
187_51 = -_56;
188_1 = (int) _51;
189_25 = MAX_EXPR <_1, max_38>;
190_31 = _1 | -2147483648;
191iftmp.0_27 = (unsigned int) _31;
192.MASK_STORE (datap_44, 8B, _35, iftmp.0_27);
193_26 = MAX_EXPR <tmp_24, max_38>;
194max_5 = _35 ? _25 : _26;
195i_29 = i_42 + 1;
196datap_30 = datap_44 + 4;
197if (w_22 > i_29)
198  goto <bb 16>; [89.00%]
199else
200  goto <bb 9>; [11.00%]
201;;  succ:       16

So here we have a reduction for MAX_EXPR, but there's 2 MAX_EXPR which can be
merge together with MAX_EXPR <max_38, ABS_EXPR <tmp>>

manually change the loop to below, then it can be vectorized.

    for (j = 0; j < t1->h; ++j) {
        const OPJ_UINT32 w = t1->w;
        for (i = 0; i < w; ++i, ++datap) {
            OPJ_INT32 tmp = *datap;
            if (tmp < 0)
              {
                OPJ_UINT32 tmp_unsigned;
                tmp_unsigned = opj_to_smr(tmp);
                memcpy(datap, &tmp_unsigned, sizeof(OPJ_INT32));
                tmp = -tmp;
              }
            max = opj_int_max(max, tmp);
        }
    }

maybe it's related to phiopt?

  parent reply	other threads:[~2023-11-01  1:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-28 19:15 [Bug middle-end/110015] New: " hubicka at gcc dot gnu.org
2023-05-28 19:42 ` [Bug middle-end/110015] " hubicka at gcc dot gnu.org
2023-10-31 12:08 ` zhangjungcc at gmail dot com
2023-11-01  1:15 ` crazylht at gmail dot com [this message]
2023-11-01  1:28 ` crazylht at gmail dot com
2023-11-07  1:12 ` pinskia at gcc dot gnu.org
2023-11-07  2:14 ` pinskia at gcc dot gnu.org
2023-11-07  2:14 ` pinskia at gcc dot gnu.org
2023-11-07  2:42 ` pinskia at gcc dot gnu.org
2023-11-07  2:50 ` pinskia at gcc dot gnu.org
2023-11-24 23:22 ` hubicka 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-110015-4-QB36VboRco@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).