From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23913 invoked by alias); 21 Apr 2007 15:37:47 -0000 Received: (qmail 23877 invoked by uid 48); 21 Apr 2007 15:37:31 -0000 Date: Sat, 21 Apr 2007 15:37:00 -0000 Message-ID: <20070421153731.23876.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/31136] [4.2 Regression] FRE ignores bit-field truncation (C and C++ front-end don't produce bit-field truncation In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-04/txt/msg01548.txt.bz2 ------- 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 () 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 ; sD.1526.b6D.1525 = 31 while on the trunk # SFT.0_10 = VDEF { 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; D.1533; D.1532; D.1531; D.1530; : 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 ; 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