]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fold-const.c (fold): Strip NOPs that change the signedness for RSHIFT too.
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 28 Feb 2004 07:33:10 +0000 (07:33 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 28 Feb 2004 07:33:10 +0000 (07:33 +0000)
* fold-const.c (fold): Strip NOPs that change the signedness
for RSHIFT too.  Expand comment.

From-SVN: r78603

gcc/ChangeLog
gcc/fold-const.c

index 879bbfcf17054ff3f800e259022230cad1b2ce19..8722e946c578d8b6ebb30083c35316be0ffe2382 100644 (file)
@@ -1,8 +1,13 @@
+2004-02-28  Eric Botcazou  <ebotcazou@act-europe.fr>
+
+       * fold-const.c (fold): Strip NOPs that change the signedness
+       for RSHIFT too.  Expand comment.
+
 2004-02-27  Ian Lance Taylor  <ian@wasabisystems.com>
 
        PR optimization/7871
        * flow.c (mark_set_1): Don't add LOG_LINKS for global registers
-       from or to call insns.  
+       from or to call insns.
 
 2004-02-27  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
index 9178a34417821dd5836908b6d4991513231f0814..04452de6c7f65c50da0511719b837a327a710553 100644 (file)
@@ -5423,14 +5423,20 @@ fold (tree expr)
          if (op == 0)
            continue;           /* Valid for CALL_EXPR, at least.  */
 
-         if (kind == '<' || code == RSHIFT_EXPR)
-           {
-             /* Signedness matters here.  Perhaps we can refine this
-                later.  */
-             STRIP_SIGN_NOPS (op);
-           }
+         /* Strip any conversions that don't change the mode.  This is
+            safe for every expression, except for a comparison expression
+            because its signedness is derived from its operands.  So, in
+            the latter case, only strip conversions that don't change the
+            signedness.
+
+            Note that this is done as an internal manipulation within the
+            constant folder, in order to find the simplest representation
+            of the arguments so that their form can be studied.  In any
+            cases, the appropriate type conversions should be put back in
+            the tree that will get out of the constant folder.  */
+         if (kind == '<')
+           STRIP_SIGN_NOPS (op);
          else
-           /* Strip any conversions that don't change the mode.  */
            STRIP_NOPS (op);
 
          if (TREE_CODE (op) == COMPLEX_CST)