public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ktietz at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/59429] Missed optimization opportunity in qsort-style comparison functions
Date: Fri, 04 Apr 2014 11:37:00 -0000	[thread overview]
Message-ID: <bug-59429-4-iO01aEOC8q@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59429-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59429

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-04-04
                 CC|                            |ktietz at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #4 from Kai Tietz <ktietz at gcc dot gnu.org> ---
This issue seems to be another problem caused by missing unification of
expressions.

For given example we get for 'comGE' the following gimple:

comGE (int a, int b)
{
  int iftmp.8_1;
  int _2;
  _Bool _6;
  int _7;

  <bb 2>:
  if (a_3(D) <= b_4(D))
    goto <bb 3>;
  else
    goto <bb 4>;

  <bb 3>:
  _6 = a_3(D) != b_4(D);
  _2 = (int) _6;
  _7 = -_2;

  <bb 4>:
  # iftmp.8_1 = PHI <_7(3), 1(2)>
  return iftmp.8_1;

}

As we see we don't optimize out the negate case.
For expression:
  (a_3(D) > b_4(D) ? 1 : -((int) (a_3(D) != b_4(D))))
we should transform it instead to:
  (a_3(D) < b_4(D) ? -1 : (int) (a_3(D) != b_4(D)))

The reference to gold's --icf option looks for me wrong here.  Such
optimizations - as done here for gold - can't be done by gcc.  At least not for
the given example provided.  In other TUs there always might users of direct
function-address in comparison.  So to find and reduce identical code-blocks is
just a linker feature (with some danger IMHO).

So back to this issue.  I would think it is more a problem to be solved on
gimple, and not that much a RTL issue in first hand.


  parent reply	other threads:[~2014-04-04 11:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 11:35 [Bug rtl-optimization/59429] New: " jengelh at inai dot de
2013-12-09 13:16 ` [Bug rtl-optimization/59429] " hjl.tools at gmail dot com
2013-12-09 14:02 ` jengelh at inai dot de
2013-12-09 14:05 ` jengelh at inai dot de
2014-04-04 11:37 ` ktietz at gcc dot gnu.org [this message]
2014-05-02 15:58 ` law at redhat dot com
2014-05-02 15:59 ` law at redhat dot com
2014-05-02 16:03 ` ktietz at gcc dot gnu.org
2014-05-02 16:09 ` law at redhat dot com
2014-05-02 16:14 ` ktietz at gcc dot gnu.org
2014-05-02 16:33 ` law at redhat dot com
2014-05-02 16:42 ` ktietz at gcc dot gnu.org
2014-05-05  8:48 ` rguenth at gcc dot gnu.org
2014-05-30  8:33 ` ktietz at gcc dot gnu.org
2021-07-25  0:22 ` [Bug tree-optimization/59429] " pinskia at gcc dot gnu.org
2024-01-24 16:56 ` pinskia at gcc dot gnu.org
2024-03-22 10:55 ` redbeard0531 at gmail dot com

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-59429-4-iO01aEOC8q@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).