public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "spark 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: Fri, 23 Mar 2007 05:01:00 -0000	[thread overview]
Message-ID: <20070323050100.27943.qmail@sourceware.org> (raw)
In-Reply-To: <bug-31136-12896@http.gcc.gnu.org/bugzilla/>



------- Comment #7 from spark at gcc dot gnu dot org  2007-03-23 05:00 -------
Follow up on Joseph's analysis:

The problematic STRIP_SIGN_NOPS() call is from fold_unary()
which is called from try_combine_conversion() in tree-ssa-pre.c.

STRIP_SIGN_NOPS() is called with the expression:

 <nop_expr 0x866f220
    type <integer_type 0xf7e30678 public unsigned QI
        size <integer_cst 0xf7d781e0 constant invariant 8>
        unit size <integer_cst 0xf7d781f8 constant invariant 1>
        align 8 symtab 0 alias set -1 precision 4 min <integer_cst 0xf7e32618
0> max <integer_cst 0xf7e32630 15>>

    arg 0 <integer_cst 0xf7e327b0 type <integer_type 0xf7e306d4> constant
invariant 31>>

and it stripes away the conversion,
leaving only integer constant 31.
This is clearly wrong as it removes the downconversion of precision.

Following patch (against 4.2 branch) seems to fix the problem:

Index: tree.h
===================================================================
--- tree.h      (revision 123088)
+++ tree.h      (working copy)
@@ -912,7 +912,9 @@ extern void omp_clause_range_check_faile
         && (TYPE_MODE (TREE_TYPE (EXP))                        \
             == TYPE_MODE (TREE_TYPE (TREE_OPERAND (EXP, 0))))  \
         && (TYPE_UNSIGNED (TREE_TYPE (EXP))                    \
-            == TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (EXP, 0))))) \
+            == TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (EXP, 0))))\
+        && (TYPE_PRECISION (TREE_TYPE (EXP))                   \
+            >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (EXP, 0)))))\
     (EXP) = TREE_OPERAND (EXP, 0)

 /* Like STRIP_NOPS, but don't alter the TREE_TYPE either.  */


-- 


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


  parent reply	other threads:[~2007-03-23  5:01 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 [this message]
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
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=20070323050100.27943.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).