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 tree-optimization/113024] Nested cast not optimized out in GIMPLE
Date: Fri, 15 Dec 2023 09:14:39 +0000	[thread overview]
Message-ID: <bug-113024-4-zIymQZJctR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113024-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:330f1e078dae257d4f8f7b13299ececc2344e681

commit r14-6580-g330f1e078dae257d4f8f7b13299ececc2344e681
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Dec 15 10:13:44 2023 +0100

    match.pd: Optimize sign-extension followed by truncation [PR113024]

    While looking at a bitint ICE, I've noticed we don't optimize
    in f1 and f5 functions below the 2 casts into just one at GIMPLE,
    even when optimize it in convert_to_integer if it appears in the same
    stmt.  The large match.pd simplification of two conversions in a row
    has many complex rules and as the testcase shows, everything else from
    the narrowest -> widest -> prec_in_between all integer conversions
    is already handled, either because the inside_unsignedp == inter_unsignedp
    rule kicks in, or the
             && ((inter_unsignedp && inter_prec > inside_prec)
                 == (final_unsignedp && final_prec > inter_prec))
    one, but there is no reason why sign extension to from narrowest to
    widest type followed by truncation to something in between can't be
    done just as sign extension from narrowest to the final type.  After all,
    if the widest type is signed rather than unsigned, regardless of the final
    type signedness we already handle it that way.
    And since PR93044 we also handle it if the final precision is not wider
    than the inside precision.

    2023-12-15  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/113024
            * match.pd (two conversions in a row): Simplify scalar integer
            sign-extension followed by truncation.

            * gcc.dg/tree-ssa/pr113024.c: New test.

  parent reply	other threads:[~2023-12-15  9:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-14 16:36 [Bug tree-optimization/113024] New: " jakub at gcc dot gnu.org
2023-12-14 17:52 ` [Bug tree-optimization/113024] " pinskia at gcc dot gnu.org
2023-12-14 17:55 ` jakub at gcc dot gnu.org
2023-12-14 17:59 ` pinskia at gcc dot gnu.org
2023-12-15  9:14 ` cvs-commit at gcc dot gnu.org [this message]
2023-12-15  9:28 ` jakub 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-113024-4-zIymQZJctR@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).