Fix miscompilation of testcase 20021010-1.c for v850 target with -O -mv850e.
authorJim Wilson <wilson@redhat.com>
Thu, 10 Oct 2002 19:40:34 +0000 (19:40 +0000)
committerJim Wilson <wilson@gcc.gnu.org>
Thu, 10 Oct 2002 19:40:34 +0000 (12:40 -0700)
* cse.c (fold_rtx): Don't perform associative optimization for DIV and
UDIV.

From-SVN: r58026

gcc/ChangeLog
gcc/cse.c

index 2ec22582d7a740d63c417eda21e9f36e48b83d7b..8206b2d76e687cc52323485ce08b63509422cc92 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-10  Jim Wilson  <wilson@redhat.com>
+
+       * cse.c (fold_rtx): Don't perform associative optimization for DIV and
+       UDIV.
+
 2002-10-10  David Edelsohn  <edelsohn@gnu.org>
 
        * config/rs6000/aix52.h: New file.
index 75182d8670fc0d168f4c8ff3de58fec0c5439ecc..378a91292b3599309de63b1e593713011c645212 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -4212,7 +4212,7 @@ fold_rtx (x, insn)
        from_plus:
        case SMIN:    case SMAX:      case UMIN:    case UMAX:
        case IOR:     case AND:       case XOR:
-       case MULT:    case DIV:       case UDIV:
+       case MULT:
        case ASHIFT:  case LSHIFTRT:  case ASHIFTRT:
          /* If we have (<op> <reg> <const_int>) for an associative OP and REG
             is known to be of similar form, we may be able to replace the
@@ -4260,11 +4260,9 @@ fold_rtx (x, insn)
                break;
 
              /* Compute the code used to compose the constants.  For example,
-                A/C1/C2 is A/(C1 * C2), so if CODE == DIV, we want MULT.  */
+                A-C1-C2 is A-(C1 + C2), so if CODE == MINUS, we want PLUS.  */
 
-             associate_code
-               = (code == MULT || code == DIV || code == UDIV ? MULT
-                  : is_shift || code == PLUS || code == MINUS ? PLUS : code);
+             associate_code = (is_shift || code == MINUS ? PLUS : code);
 
              new_const = simplify_binary_operation (associate_code, mode,
                                                     const_arg1, inner_const);
@@ -4302,6 +4300,14 @@ fold_rtx (x, insn)
            }
          break;
 
+       case DIV:       case UDIV:
+         /* ??? The associative optimization performed immediately above is
+            also possible for DIV and UDIV using associate_code of MULT.
+            However, we would need extra code to verify that the
+            multiplication does not overflow, that is, there is no overflow
+            in the calculation of new_const.  */
+         break;
+
        default:
          break;
        }