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 rtl-optimization/94543] missed optimization with MIN and AND with type promotion
Date: Tue, 14 Apr 2020 06:44:31 +0000	[thread overview]
Message-ID: <bug-94543-4-TYZvQovnYe@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94543-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Version|tree-ssa                    |10.0
   Last reconfirmed|                            |2020-04-14
             Status|UNCONFIRMED                 |NEW
             Target|                            |x86_64-*-* i?86-*-*
           Keywords|                            |missed-optimization
          Component|middle-end                  |rtl-optimization

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that we fail to have a proper representation of the target on the
GIMPLE level.  We expand to RTL from the optimal

  <bb 2> [local count: 1073741824]:
  # RANGE [0, 255] NONZERO 255
  _1 = MIN_EXPR <x_2(D), 255>;
  # RANGE [0, 255] NONZERO 255
  _3 = (unsigned int) _1;
  return _3;

but that produces

(insn 10 6 9 (set (reg:HI 88)
        (const_int 255 [0xff])) "x.c":1:56 -1
     (nil))

(insn 9 10 11 (set (reg:CC 17 flags)
        (compare:CC (reg/v:HI 84 [ x ])
            (const_int 255 [0xff]))) "x.c":1:56 -1
     (nil))

(insn 11 9 12 (set (reg:HI 87)
        (if_then_else:HI (leu (reg:CC 17 flags)
                (const_int 0 [0]))
            (reg/v:HI 84 [ x ])
            (reg:HI 88))) "x.c":1:56 -1
     (nil))

(insn 12 11 13 (set (reg:SI 86)
        (zero_extend:SI (reg:HI 87))) "x.c":1:61 -1
     (nil))

given fort the (unsigned int) _1 zero-extension we don't have any other
representation on GIMPLE to elide the zero-extension.  I'm also not
sure if (subreg:SI (reg:HI 87)) would be correct in all cases.

Marking rtl-optimization but eventually it's also a target issue.

We also don't have anything like a reg-note to tell ranges of a
set?  Anyway, even on RTL the range of reg:HI 87 is clearly visible.

      reply	other threads:[~2020-04-14  6:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 19:13 [Bug middle-end/94543] New: " rth at gcc dot gnu.org
2020-04-14  6:44 ` rguenth 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-94543-4-TYZvQovnYe@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).