public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rask at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/3507] appalling optimisation with sub/cmp on multiple targets
Date: Thu, 29 Nov 2007 00:10:00 -0000	[thread overview]
Message-ID: <20071129000952.30215.qmail@sourceware.org> (raw)
In-Reply-To: <bug-3507-98@http.gcc.gnu.org/bugzilla/>



------- Comment #11 from rask at gcc dot gnu dot org  2007-11-29 00:09 -------
In reply to comment #10 from Steven Bosscher 2007-11-28 22:02:

> > +  for (defs = DF_INSN_DEFS (insn);
> > +       *defs && DF_REF_REGNO (*defs) != REGNO (x);
> > +       defs++)
> > +    ;

> Are you aware of df_find_def() ?

   Not until now, and it won't work either, because it uses rtx_equal_p() and
the mode of DF_REF_REG() doesn't match that of the REG rtx in the insn. See
also <URL:http://gcc.gnu.org/ml/gcc/2007-11/msg00719.html>.

> IMNSHO, computing DEF-USE chains for this niche optimization loses in the
> cost/benefit trade-off.

   The split of the comparison setter and the comparison user across two
insns with no link between them is an interesting case of poor
infrastructure. Most back ends can't emit the setter before they know what
the user looks like and therefore always emit the two back-to-back. At the
same time, several passes need to find one from the other but can't rely on
them to be back-to-back and because there's no link between them (except if
by DEF-USE/USE-DEF), they have to roll their own means of doing so.

   (So yes, it's been done without DEF-USE before and it can be done without
DEF-USE again.)

> I wonder if you can't just integrate this optimization in cse.c as-is by
> recording an equivalence "a < b" == "signof(c)" when you process "a - b".

   That doesn't catch the unsigned comparison. Actually, how would I even
know if it is unsigned or not?

> In any case, adding this optimization to cse.c is Just Wrong (tm).  I
> don't understand why you didn't even try to optimize this in one of the
> tree optimizers instead.  I thought it was clear GCC is trying to reduce
> its dependency on RTL optimizations?

   There's no way to optimize the signed case with -fwrapv (e.g. Java) at
the tree level, because we can't arrange for a - b to be computed in the
same instruction as a < b. At the RTL level, it is merely difficult. That
makes it less interesting to work on this optimization at the tree level.


-- 


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


  parent reply	other threads:[~2007-11-29  0:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-3507-98@http.gcc.gnu.org/bugzilla/>
2007-08-23 20:10 ` eweddington at cso dot atmel dot com
2007-11-02 14:18 ` rask at gcc dot gnu dot org
2007-11-27 18:04 ` rask at gcc dot gnu dot org
2007-11-28 18:01 ` rask at gcc dot gnu dot org
2007-11-28 22:02 ` steven at gcc dot gnu dot org
2007-11-29  0:10 ` rask at gcc dot gnu dot org [this message]
2007-11-29 11:43 ` bonzini at gnu dot org
     [not found] <bug-3507-4@http.gcc.gnu.org/bugzilla/>
2012-07-10 10:24 ` daniel.santos at pobox dot com
2012-07-10 10:55 ` owner at bugs dot debian.org
2020-07-22 16:51 ` josephcsible at gmail dot com
2021-06-15  6:24 ` vanyacpp at gmail dot com
2023-05-13  5:55 ` 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=20071129000952.30215.qmail@sourceware.org \
    --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).