fold-const.c (fold): Yet another COND_EXPR bug...
authorRichard Henderson <rth@cygnus.com>
Sun, 20 Sep 1998 12:37:58 +0000 (05:37 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Sun, 20 Sep 1998 12:37:58 +0000 (05:37 -0700)
        * fold-const.c (fold): Yet another COND_EXPR bug: when folding
        to an ABS expr, convert an unsigned input to signed.

From-SVN: r22503

gcc/ChangeLog
gcc/fold-const.c

index ffb1a6bc2807fdfad422edd9607b585adc96f10a..1f58e78ed6009ffd5ca7660e59fc7e82cd140fab 100644 (file)
@@ -1,3 +1,8 @@
+Sun Sep 20 12:35:55 1998  Richard Henderson  <rth@cygnus.com>
+
+       * fold-const.c (fold): Yet another COND_EXPR bug: when folding 
+       to an ABS expr, convert an unsigned input to signed.
+       
 Sun Sep 20 12:14:45 1998  Jeffrey A Law  (law@cygnus.com)
 
        * fold-const.c (fold): Fix another type in COND_EXPR handling code.
index b7037deeea7c8acf6a7b07f0ffbfb6bbac1b0d13..0d04e91160b0af91f467e8d9497641c302cfe7c3 100644 (file)
@@ -5863,11 +5863,15 @@ fold (expr)
                return pedantic_non_lvalue (convert (type, arg1));
              case GE_EXPR:
              case GT_EXPR:
+               if (TREE_UNSIGNED (TREE_TYPE (arg1)))
+                 arg1 = convert (signed_type (TREE_TYPE (arg1)), arg1);
                return pedantic_non_lvalue
                  (convert (type, fold (build1 (ABS_EXPR,
                                                TREE_TYPE (arg1), arg1))));
              case LE_EXPR:
              case LT_EXPR:
+               if (TREE_UNSIGNED (TREE_TYPE (arg1)))
+                 arg1 = convert (signed_type (TREE_TYPE (arg1)), arg1);
                return pedantic_non_lvalue
                  (fold (build1 (NEGATE_EXPR, type,
                                 convert (type,