(fold_rtx): For SUBREG, actually test subreg_lowpart_p in the code to handle narrowin...
authorRichard Stallman <rms@gnu.org>
Sat, 19 Sep 1992 04:48:37 +0000 (04:48 +0000)
committerRichard Stallman <rms@gnu.org>
Sat, 19 Sep 1992 04:48:37 +0000 (04:48 +0000)
(fold_rtx): For SUBREG, actually test subreg_lowpart_p in the
code to handle narrowing subregs.  And exclude binary ops like DIV
where truncating the args is not valid.

From-SVN: r2160

gcc/cse.c

index e76a1300d81acc0352d40b5c574bac79e47c52a8..85ecc774842228bdb0d844748f75e3ccbb1376e8 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -4457,7 +4457,8 @@ fold_rtx (x, insn)
         can use the inner value.  */
 
       if (GET_CODE (folded_arg0) == REG
-         && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (folded_arg0)))
+         && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (folded_arg0))
+         && subreg_lowpart_p (x))
        {
          struct table_elt *elt;
 
@@ -4472,6 +4473,8 @@ fold_rtx (x, insn)
 
          for (; elt; elt = elt->next_same_value)
            {
+             enum rtx_code eltcode = GET_CODE (elt->exp);
+
              /* Just check for unary and binary operations.  */
              if (GET_RTX_CLASS (GET_CODE (elt->exp)) == '1'
                  && GET_CODE (elt->exp) != SIGN_EXTEND
@@ -4491,6 +4494,10 @@ fold_rtx (x, insn)
                }
              else if ((GET_RTX_CLASS (GET_CODE (elt->exp)) == '2'
                        || GET_RTX_CLASS (GET_CODE (elt->exp)) == 'c')
+                      && eltcode != DIV && eltcode != MOD
+                      && eltcode != UDIV && eltcode != UMOD
+                      && eltcode != ASHIFTRT && eltcode != LSHIFTRT
+                      && eltcode != ROTATE && eltcode != ROTATERT
                       && ((GET_CODE (XEXP (elt->exp, 0)) == SUBREG
                            && (GET_MODE (SUBREG_REG (XEXP (elt->exp, 0)))
                                == mode))