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/102705] [12 Regression] Dead Code Elimination Regression at -O3 since r12-2637-g145bc41dae7c7bfa093d61e77346f98e6a595a0e
Date: Wed, 19 Jan 2022 09:18:56 +0000	[thread overview]
Message-ID: <bug-102705-4-45LuCELDo9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102705-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
so it's _10 == _10 ^ 1 vs. (short) _2 == (short)(((char) _2) ^ 1)

likely simplified using logical_inverted_value which works fine for the first
but not the second form.  We're now doing more simplification (looking
through some extra conversions), but that prevents this pattern from matching.

By the time we compute the ranges necessary the conversions are already
pickled too far before simplifying the conditional.

Handling possible variants with patterns is a bit difficult, instead what
looks necessary here is some sort of symbolic equivalence processing that
would include bit ops so it tracks that _6 is _2 and _22 is _2 ^ 1.

What would also help here is simplifying

  # RANGE [0, 1] NONZERO 1
  _2 = 1 >> b.1_1;
  # RANGE [0, 1] NONZERO 1
  iftmp.0_10 = (char) _2;
  # RANGE [0, 1] NONZERO 1
  _4 = iftmp.0_10 ^ 1;
  # RANGE [0, 1] NONZERO 1
  _5 = (int) _4;
  # RANGE [0, 1] NONZERO 1
  iftmp.6_22 = (short int) _5;

via ((char)_2) ^ 1 -> (char)(_2 ^ 1) though we generally do not widen ops.
Which means doing it one level more outer at (int)((char) _2) ^ 1)
-> _2 ^ 1 which is possible because the truncation is a no-op.  That could
be applied to all bit ops when we have range info on the non-constant
operand for the case where the wider type fits in a GPR.

  parent reply	other threads:[~2022-01-19  9:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12 13:41 [Bug tree-optimization/102705] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
2021-10-12 13:51 ` [Bug tree-optimization/102705] [12 Regression] Dead Code Elimination Regression at -O3 since r12-2637-g145bc41dae7c7bfa093d61e77346f98e6a595a0e marxin at gcc dot gnu.org
2021-10-13  6:22 ` rguenth at gcc dot gnu.org
2021-10-13 19:25 ` amacleod at redhat dot com
2022-01-19  9:18 ` rguenth at gcc dot gnu.org [this message]
2022-05-06  8:31 ` [Bug tree-optimization/102705] [12/13 " jakub at gcc dot gnu.org
2022-10-19  9:35 ` rguenth at gcc dot gnu.org
2023-05-08 12:22 ` [Bug tree-optimization/102705] [12/13/14 " rguenth at gcc dot gnu.org
2024-02-21  7:00 ` pinskia 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-102705-4-45LuCELDo9@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).