public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/105137] Missed optimization 64-bit adds and shifts
Date: Sun, 01 Jan 2023 17:01:39 +0000	[thread overview]
Message-ID: <bug-105137-4-ku4A9hRsdq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105137-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:4f1314f547f69d3a2b1f16ce301267e3bfb4e427

commit r13-4945-g4f1314f547f69d3a2b1f16ce301267e3bfb4e427
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Sun Jan 1 17:00:28 2023 +0000

    Add post-reload splitter for extendditi2 on x86_64.

    This is another step towards a possible solution for PR 105137.
    This patch introduces a define_insn for extendditi2 that allows
    DImode to TImode sign-extension to be represented in the early
    RTL optimizers, before being split post-reload into the exact
    same idiom as currently produced by RTL expansion.

    Typically this produces the identical code, so the first new
    test case:
    __int128 foo(long long x) { return (__int128)x; }

    continues to generate:
    foo:    movq    %rdi, %rax
            cqto
            ret

    The "magic" is that this representation allows combine and the
    other RTL optimizers to do a better job.  Hence, the second
    test case:

    __int128 foo(__int128 a, long long b) {
        a += ((__int128)b) << 70;
        return a;
    }

    which mainline with -O2 currently generates as:

    foo:    movq    %rsi, %rax
            movq    %rdx, %rcx
            movq    %rdi, %rsi
            salq    $6, %rcx
            movq    %rax, %rdi
            xorl    %eax, %eax
            movq    %rcx, %rdx
            addq    %rsi, %rax
            adcq    %rdi, %rdx
            ret

    with this patch now becomes:
    foo:    movl    $0, %eax
            salq    $6, %rdx
            addq    %rdi, %rax
            adcq    %rsi, %rdx
            ret

    i.e. the same code for the signed and unsigned extension variants.

    2023-01-01  Roger Sayle  <roger@nextmovesoftware.com>
                Uroš Bizjak  <ubizjak@gmail.com>

    gcc/ChangeLog
            * config/i386/i386.md (extendditi2): New define_insn.
            (define_split): Use DWIH mode iterator to treat new extendditi2
            identically to existing extendsidi2_1.
            (define_peephole2): Likewise.
            (define_peephole2): Likewise.
            (define_Split): Likewise.

    gcc/testsuite/ChangeLog
            * gcc.target/i386/extendditi2-1.c: New test case.
            * gcc.target/i386/extendditi2-2.c: Likewise.

      parent reply	other threads:[~2023-01-01 17:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-02 14:01 [Bug middle-end/105137] New: " andre.schackier at gmail dot com
2022-11-28 20:03 ` [Bug middle-end/105137] " pinskia at gcc dot gnu.org
2023-01-01 17:01 ` cvs-commit at gcc dot gnu.org [this message]

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-105137-4-ku4A9hRsdq@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).