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/107006] Missing optimization: common idiom for external data
Date: Thu, 22 Sep 2022 07:08:08 +0000	[thread overview]
Message-ID: <bug-107006-4-CeOnURBGBY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107006-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|rtl-optimization            |tree-optimization
   Last reconfirmed|                            |2022-09-22
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
The reason is that the loops are not unrolled (early enough or at all) for the
bswap/load detection.  So to work you have to unroll the loops manually or
direct GCC to do that, for example

inline uint64_t get_le64 (const unsigned char x[64/8]) {
 uint64_t y = 0;
#pragma GCC unroll 8
for (size_t i = 0; i < sizeof y; i++)
 if (0) y |= (uint64_t)x[i] << ((sizeof y - 1 - i)*8);
 else y |= (uint64_t)x[i] << i*8; return y; 
}

produces

get_le64:
.LFB11:
        .cfi_startproc
        movq    (%rdi), %rax
        ret

the unroll heuristics do not anticipate that later bswap/load detection will
merge all the loads and thus not grow code too much.

  parent reply	other threads:[~2022-09-22  7:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22  2:27 [Bug rtl-optimization/107006] New: " hpa at zytor dot com
2022-09-22  2:28 ` [Bug rtl-optimization/107006] " hpa at zytor dot com
2022-09-22  2:28 ` hpa at zytor dot com
2022-09-22  2:28 ` hpa at zytor dot com
2022-09-22  2:29 ` hpa at zytor dot com
2022-09-22  2:30 ` hpa at zytor dot com
2022-09-22  2:30 ` hpa at zytor dot com
2022-09-22  2:30 ` hpa at zytor dot com
2022-09-22  2:31 ` hpa at zytor dot com
2022-09-22  2:32 ` hpa at zytor dot com
2022-09-22  7:08 ` rguenth at gcc dot gnu.org [this message]
2022-09-22 14:26 ` [Bug tree-optimization/107006] " hpa at zytor dot com
2022-09-23  6:11 ` 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-107006-4-CeOnURBGBY@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).