public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/52631] [4.6/4.7/4.8 Regression] VN does not use simplified expression for lookup
Date: Wed, 21 Mar 2012 00:30:00 -0000	[thread overview]
Message-ID: <bug-52631-4-BQR4CedVt9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52631-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-03-21 00:14:37 UTC ---
(In reply to comment #3)
> Hmm, but then you'd pessimize the case where b_2 & 1 were available?  Thus,
> don't you need to do the lookup with the original expression anyway if the
> lookup for the simplified expression fails?  Oh, and doesn't the testcase
> show a missed canonicalization?

My patch just gets us back to where we were before tuples.
Before tuples we would do:

      else if (simplified)
        {
          if (TREE_CODE (lhs) == SSA_NAME)
        {
          VN_INFO (lhs)->has_constants = expr_has_constants (simplified);
          /* We have to unshare the expression or else
             valuizing may change the IL stream.  */
          VN_INFO (lhs)->expr = unshare_expr (simplified);
        }
          rhs = simplified;
        }

And then use rhs in the switch statement for visit_unary_op/visit_binary_op .

I don't see a missed canonicalization anywhere as we are combing (a>>31)&1 and
then calling fold on it and it returns a>>31 which is the correct thing to do. 
The main issue is we never do a lookup on a>>31 after we do the simplification,
we only do it on the b&1.  

Let me see if I can understand the question about b&1 being available, a
testcase would be something like:
unsigned f(unsigned a, unsigned b, unsigned c)
{
  unsigned d = c&1;
  if(b)
    c = a>>31;
  return (c & 1) + d;
}

--- CUT ---
PRE produces (with both the patch and before):
<bb 2>:
  d_3 = c_2(D) & 1;
  if (b_4(D) != 0)
    goto <bb 3>;
  else
    goto <bb 5>;

<bb 5>:
  goto <bb 4>;

<bb 3>:
  c_6 = a_5(D) >> 31;
  pretmp.3_11 = c_6 & 1;

<bb 4>:
  # c_1 = PHI <c_2(D)(5), c_6(3)>
  # prephitmp.4_12 = PHI <d_3(5), pretmp.3_11(3)>
  D.1713_7 = prephitmp.4_12;
  D.1712_8 = D.1713_7 + d_3;
  return D.1712_8;

Which means we don't even do the simplifications while doing a PRE anyways.


  parent reply	other threads:[~2012-03-21  0:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-20  6:09 [Bug tree-optimization/52631] New: " pinskia at gcc dot gnu.org
2012-03-20  6:58 ` [Bug tree-optimization/52631] [4.6/4.7/4.8 Regression] " pinskia at gcc dot gnu.org
2012-03-20  7:34 ` pinskia at gcc dot gnu.org
2012-03-20 11:20 ` rguenth at gcc dot gnu.org
2012-03-21  0:30 ` pinskia at gcc dot gnu.org [this message]
2012-03-24  3:21 ` pinskia at gcc dot gnu.org
2012-03-24  5:06 ` pinskia at gcc dot gnu.org
2012-04-13 13:10 ` rguenth at gcc dot gnu.org
2012-06-14  8:21 ` rguenth at gcc dot gnu.org
2012-09-20 10:18 ` jakub at gcc dot gnu.org
2013-01-20  5:01 ` law at gcc dot gnu.org
2013-01-20  5:02 ` law at redhat dot com
2013-03-04 11:13 ` gjl 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-52631-4-BQR4CedVt9@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).