public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "segher at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/110717] Double-word sign-extension missed-optimization Date: Fri, 21 Jul 2023 16:28:10 +0000 [thread overview] Message-ID: <bug-110717-4-hfQQE3UFPc@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110717-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110717 --- Comment #13 from Segher Boessenkool <segher at gcc dot gnu.org> --- So. Before expand we have _6 = (__int128) x_3(D); x.0_1 = _6 << 59; _2 = x.0_1 >> 59; _4 = (__int128 unsigned) _2; return _4; That should have been optimised better :-( The RTL code it expands to sets the same pseudo multiple times. Bad bad bad. This hampers many optimisations. Like: (insn 6 3 7 2 (set (reg:DI 124) (lshiftrt:DI (reg:DI 129 [ x+8 ]) (const_int 5 [0x5]))) "110717.c":6:11 299 {lshrdi3} (nil)) (insn 7 6 8 2 (set (reg:DI 132) (ashift:DI (reg:DI 128 [ x ]) (const_int 59 [0x3b]))) "110717.c":6:11 289 {ashldi3} (nil)) (insn 8 7 9 2 (set (reg:DI 132) (ior:DI (reg:DI 124) (reg:DI 132))) "110717.c":6:11 233 {*booldi3} (nil)) (They are subregs right after expand, totally unreadable; this is after subreg1, slightly more readable, but essentially the same code still). The web pass eventually gets rid of the double set in this case. Because the shift-left-then-right survives all the way to combine, it (being the greedy bastard that it is) will use the combiner patterns rs6000 has for multi-precision shifts, before it would notice the two (multiprecision!) shifts together are largely a no-op, so you get stuck at a local optimum. Pat for the course for combine :-/
next prev parent reply other threads:[~2023-07-21 16:28 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-18 14:32 [Bug rtl-optimization/110717] New: " jakub at gcc dot gnu.org 2023-07-18 14:33 ` [Bug rtl-optimization/110717] " jakub at gcc dot gnu.org 2023-07-18 14:54 ` jakub at gcc dot gnu.org 2023-07-19 6:38 ` rguenth at gcc dot gnu.org 2023-07-19 8:55 ` ubizjak at gmail dot com 2023-07-19 9:00 ` jakub at gcc dot gnu.org 2023-07-19 9:30 ` ubizjak at gmail dot com 2023-07-20 18:56 ` cvs-commit at gcc dot gnu.org 2023-07-20 19:03 ` ubizjak at gmail dot com 2023-07-20 19:19 ` jakub at gcc dot gnu.org 2023-07-20 19:21 ` jakub at gcc dot gnu.org 2023-07-21 9:06 ` jakub at gcc dot gnu.org 2023-07-21 10:53 ` segher at gcc dot gnu.org 2023-07-21 16:28 ` segher at gcc dot gnu.org [this message] 2023-07-21 16:46 ` pinskia at gcc dot gnu.org 2023-08-04 15:26 ` cvs-commit at gcc dot gnu.org 2023-10-30 16:18 ` cvs-commit at gcc dot gnu.org 2023-12-13 13:37 ` cvs-commit at gcc dot gnu.org 2024-05-07 7:41 ` 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-110717-4-hfQQE3UFPc@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: linkBe 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).