fold-const.c (extract_muldiv): Don't distribute and widen multiply across plus for...
authorRichard Henderson <rth@cygnus.com>
Fri, 14 Apr 2000 17:45:17 +0000 (10:45 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 14 Apr 2000 17:45:17 +0000 (10:45 -0700)
        * fold-const.c (extract_muldiv): Don't distribute and widen
        multiply across plus for non-sizetype unsigned types.

From-SVN: r33151

gcc/ChangeLog
gcc/fold-const.c

index 4465c292dfcd3ec5a388e1ca9879f5d9ae671d3e..29c1d1f22c86934a6a0fbe75cfac04c839a7ac30 100644 (file)
@@ -1,3 +1,8 @@
+2000-04-14  Richard Henderson  <rth@cygnus.com>
+
+        * fold-const.c (extract_muldiv): Don't distribute and widen
+        multiply across plus for non-sizetype unsigned types.
+
 2000-04-14  Richard Henderson  <rth@cygnus.com>
 
        * flow.c (find_auto_inc): Don't autoinc eliminable registers.
index 19b2f70320116c7bc1c858632b84192bc12048df..991dddda973062a8b3671783bfb23b48f3fcdc85 100644 (file)
@@ -4480,6 +4480,14 @@ extract_muldiv (t, c, code, wide_type)
       if (op1 == 0 || TREE_OVERFLOW (op1))
        break;
 
+      /* If we have an unsigned type is not a sizetype, we cannot widen
+        the operation since it will change the result if the original
+        computation overflowed.  */
+      if (TREE_UNSIGNED (ctype)
+         && ! TYPE_IS_SIZETYPE (ctype)
+         && ctype != type)
+       break;
+
       /* If we were able to eliminate our operation from the first side,
         apply our operation to the second side and reform the PLUS.  */
       if (t1 != 0 && (TREE_CODE (t1) != code || code == MULT_EXPR))