public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/23286] missed fully redundant expression
Date: Sun, 17 Jan 2010 12:34:00 -0000	[thread overview]
Message-ID: <20100117123429.23481.qmail@sourceware.org> (raw)
In-Reply-To: <bug-23286-7849@http.gcc.gnu.org/bugzilla/>



------- Comment #26 from rguenth at gcc dot gnu dot org  2010-01-17 12:34 -------
Created an attachment (id=19634)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19634&action=view)
updated patch

I updated the patch to apply to current trunk.

I also notice that on the testcase for PR21485 comment #36:

/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre" } */

long
NumSift (long *array, int b, unsigned long k)
{
  if (b)
    if (array[k] < array[k + 1L])
      ++k;
  return array[k];
}

/* There should be two loads left.  */

/* { dg-final { scan-tree-dump-times "= \\\*" 2 "pre" } } */
/* { dg-final { cleanup-tree-dump "pre" } } */


we properly hoist array[k] before if (b) but still insert on the else edge
of that branch for eliminating a partial redundancy (and elimination doesn't
remove that again because the value-numbers of the inserted expressions are
not equal).

This is because while we put hoisted expressions into AVAIL_OUT of the
block we inserted to we do not propagate this to its successors so
PRE insertion does not find leaders for it.

In this case, starting from

<bb 2>:
  if (b_2(D) != 0)
    goto <bb 3>;
  else
    goto <bb 6>;

<bb 6>:
  goto <bb 5>;

<bb 3>:
  D.1955_4 = k_3(D) * 4;
  D.1956_6 = array_5(D) + D.1955_4;
  D.1957_7 = *D.1956_6;
  k_8 = k_3(D) + 1;
  D.1959_9 = k_8 * 4;
  D.1960_10 = array_5(D) + D.1959_9;
  D.1961_11 = *D.1960_10;
  if (D.1957_7 < D.1961_11)
    goto <bb 4>;
  else
    goto <bb 7>;

<bb 7>:
  goto <bb 5>;

<bb 4>:

<bb 5>:
  # k_1 = PHI <k_3(D)(6), k_3(D)(7), k_8(4)>
  D.1955_13 = k_1 * 4;
  D.1956_14 = array_5(D) + D.1955_13;
  D.1964_15 = *D.1956_14;
  return D.1964_15;

we hoist into block 2 and then PRE-insert for block 5, in pred 6 the
expressions are not yet available.  In reality
they are available but they didn't go through NEW set processing yet.

I wonder if we have to extend NEW set processing to either cover
immediate dominators of dominators or succs with single preds we
hoisted to (no idea if either would confuse PRE though).


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #16803|0                           |1
        is obsolete|                            |


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


  parent reply	other threads:[~2010-01-17 12:34 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-23286-7849@http.gcc.gnu.org/bugzilla/>
2005-10-28 18:43 ` pinskia at gcc dot gnu dot org
2007-10-10 22:59 ` steven at gcc dot gnu dot org
2007-10-16 13:33 ` steven at gcc dot gnu dot org
2007-10-26  4:09 ` astrange at ithinksw dot com
2008-02-23  5:23 ` pinskia at gcc dot gnu dot org
2008-11-21  6:43 ` steven at gcc dot gnu dot org
2008-11-23 13:09 ` steven at gcc dot gnu dot org
2008-11-23 13:12 ` steven at gcc dot gnu dot org
2008-11-23 13:24 ` steven at gcc dot gnu dot org
2008-11-23 13:33 ` rguenth at gcc dot gnu dot org
2008-11-23 13:45 ` rguenth at gcc dot gnu dot org
2008-11-23 14:22 ` steven at gcc dot gnu dot org
2008-11-23 18:31 ` dberlin at dberlin dot org
2008-11-27 15:27 ` steven at gcc dot gnu dot org
2008-12-01 22:02 ` steven at gcc dot gnu dot org
2009-08-04  9:06 ` steven at gcc dot gnu dot org
2010-01-17 12:34 ` rguenth at gcc dot gnu dot org [this message]
2010-01-17 12:35 ` rguenth at gcc dot gnu dot org
2010-01-17 12:56 ` rguenth at gcc dot gnu dot org
2010-01-17 13:00 ` steven at gcc dot gnu dot org
2010-02-24  9:40 ` steven at gcc dot gnu dot org
     [not found] <bug-23286-4@http.gcc.gnu.org/bugzilla/>
2010-11-16 14:45 ` rguenth at gcc dot gnu.org
2011-07-20  0:41 ` pinskia at gcc dot gnu.org
2011-07-29 20:15 ` pinskia at gcc dot gnu.org
2012-02-15 11:23 ` rguenth at gcc dot gnu.org
2012-02-15 16:07 ` rguenth at gcc dot gnu.org
2012-02-15 18:42 ` steven at gcc dot gnu.org
2012-02-16  9:48 ` rguenther at suse dot de
2012-02-16 12:58 ` rguenth at gcc dot gnu.org
2012-02-20 12:13 ` rguenth at gcc dot gnu.org
2012-02-23 14:00 ` aldot at gcc dot gnu.org
2005-08-08 17:46 [Bug tree-optimization/23286] New: " bonzini at gcc dot gnu dot org
2005-08-08 17:46 ` [Bug tree-optimization/23286] " bonzini at gcc dot gnu dot org
2005-08-08 18:42 ` pinskia at gcc dot gnu dot org
2005-08-08 18:53 ` dberlin at gcc dot gnu dot org
2005-08-08 18:56 ` dberlin at gcc dot gnu dot org
2005-08-08 19:34 ` pinskia at gcc dot gnu dot org
2005-08-08 19:36 ` pinskia at gcc dot gnu dot org
2005-08-08 19:54 ` pinskia at gcc dot gnu dot org
2005-08-08 20:29 ` dberlin at dberlin dot org
2005-08-08 20:40 ` dberlin at dberlin dot org
2005-08-29 12:35 ` pinskia at gcc dot gnu dot 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=20100117123429.23481.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).