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/31136] [4.2 Regression] FRE ignores bit-field truncation (C and C++ front-end don't produce bit-field truncation
Date: Sat, 21 Apr 2007 15:37:00 -0000	[thread overview]
Message-ID: <20070421153731.23876.qmail@sourceware.org> (raw)
In-Reply-To: <bug-31136-12896@http.gcc.gnu.org/bugzilla/>



------- Comment #13 from rguenth at gcc dot gnu dot org  2007-04-21 16:37 -------
The interesting thing is that we

Created value VH.0 for (<unnamed-unsigned:4>) 31

The bug (compared to the trunk) is, that tree-ssa-pre.c:try_look_through_load
on the 4.2 branch manages to propagate the 31 while trunk does not
(surprisingly).

On 4.2 we have for the def_stmt

#   SFT.0D.1539_2 = V_MUST_DEF <SFT.0D.1539_1>;
sD.1526.b6D.1525 = 31

while on the trunk

# SFT.0_10 = VDEF <SFT.0_9(D)> { SFT.0 }
s.b6 = 31

and the predicate !ZERO_SSA_OPERANDS (def_stmt, SSA_OP_VIRTUAL_USES) evaluates
differently on them.  *sigh*

This causes us to have the unfolded expression created from
create_value_expr_from which we then fold incorrectly by folding
of double conversion code.

One fix is to fold the expression we generate with like

Index: tree-ssa-pre.c
===================================================================
--- tree-ssa-pre.c      (revision 124018)
+++ tree-ssa-pre.c      (working copy)
@@ -2973,6 +2973,9 @@ create_value_expr_from (tree expr, basic
       TREE_OPERAND (vexpr, i) = val;
     }

+  if (UNARY_CLASS_P (vexpr))
+    vexpr = fold (vexpr);
+
   return vexpr;
 }

which then results in the correct

main ()
{
  short unsigned int D.1536;
  short unsigned int D.1535;
  int D.1534;
  <unnamed-unsigned:6> D.1533;
  <unnamed-unsigned:4> D.1532;
  <unnamed-unsigned:4> D.1531;
  <unnamed-unsigned:6> D.1530;

<bb 2>:
  s.b6 = 31;
  D.1530_3 = 31;
  D.1531_4 = 15;
  s.b4 = D.1531_4;
  D.1532_7 = 15;
  D.1533_8 = 15;
  s.b6 = D.1533_8;
  D.1535_10 = BIT_FIELD_REF <s, 16, 0>;
  D.1536_11 = D.1535_10 & 1008;
  D.1534_12 = D.1536_11 != 240;
  return D.1534_12;

}

now another question is, why we "regressed" here on the mainline.  Danny?
(I guess we might get more unfolded trees by constants propagated by
the look from load code - like an addition)


-- 


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


  parent reply	other threads:[~2007-04-21 15:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-11 18:48 [Bug tree-optimization/31136] New: FRE ignores " TabonyEE at austin dot rr dot com
2007-03-19 23:19 ` [Bug tree-optimization/31136] " TabonyEE at austin dot rr dot com
2007-03-20  0:24 ` pinskia at gcc dot gnu dot org
2007-03-20  0:39 ` TabonyEE at austin dot rr dot com
2007-03-20  6:41 ` [Bug c/31136] " pinskia at gcc dot gnu dot org
2007-03-20 10:00 ` [Bug c/31136] [4.2 Regression] " rguenth at gcc dot gnu dot org
2007-03-22 23:14 ` [Bug c/31136] [4.2 Regression] FRE ignores bit-field truncation (C and C++ front-end don't produce " mmitchel at gcc dot gnu dot org
2007-03-23  3:45 ` [Bug tree-optimization/31136] " jsm28 at gcc dot gnu dot org
2007-03-23  5:01 ` spark at gcc dot gnu dot org
2007-03-23  7:57   ` Andrew Pinski
2007-03-23  8:01     ` Andrew Pinski
2007-03-23  7:57 ` pinskia at gmail dot com
2007-03-23  8:01 ` pinskia at gmail dot com
2007-03-23  8:18 ` pinskia at gcc dot gnu dot org
2007-03-23 13:41 ` joseph at codesourcery dot com
2007-03-26  4:43 ` mmitchel at gcc dot gnu dot org
2007-04-21 15:37 ` rguenth at gcc dot gnu dot org [this message]
2007-04-21 15:56 ` rguenth at gcc dot gnu dot org
2007-04-21 15:58 ` rguenth at gcc dot gnu dot org
2007-04-21 17:44 ` rguenth at gcc dot gnu dot org
2007-04-21 17:47 ` rguenth at gcc dot gnu dot org
2007-04-21 17:53 ` rguenth 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=20070421153731.23876.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).