combine.c (simplify_shift_const): (lshiftrt (truncate (lshiftrt))) is (truncate ...
authorJohn Carr <jfc@mit.edu>
Sun, 1 Feb 1998 01:49:32 +0000 (01:49 +0000)
committerJeff Law <law@gcc.gnu.org>
Sun, 1 Feb 1998 01:49:32 +0000 (18:49 -0700)
        * combine.c (simplify_shift_const):  (lshiftrt (truncate (lshiftrt)))
        is (truncate (lshiftrt)).

From-SVN: r17570

gcc/ChangeLog
gcc/combine.c

index 92a72da8373a68f297813ec0c959b6f5caf1487f..a37923d374cc5c14abdd1a26bb5374fcde0a6eb7 100644 (file)
@@ -1,3 +1,8 @@
+Sun Feb  1 02:50:46 1998  John Carr  <jfc@mit.edu>
+
+       * combine.c (simplify_shift_const):  (lshiftrt (truncate (lshiftrt)))
+       is (truncate (lshiftrt)).
+
 Sun Feb  1 01:06:53 1998  Richard Henderson  <rth@cygnus.com>
 
        * alpha.c (alpha_expand_unaligned_load): Use expand_binop properly.
index 3bcea7deb3ccc432797325520e6f5966b1cfc500..017cf12715ee64d17a72d121d86b5e849ca870af 100644 (file)
@@ -8787,6 +8787,28 @@ simplify_shift_const (x, code, result_mode, varop, count)
              continue;
            }
          break;
+
+       case TRUNCATE:
+         /* Change (lshiftrt (truncate (lshiftrt))) to (truncate (lshiftrt))
+            if the truncate does not affect the value.  */
+         if (code == LSHIFTRT
+             && GET_CODE (XEXP (varop, 0)) == LSHIFTRT
+             && GET_CODE (XEXP (XEXP (varop, 0), 1)) == CONST_INT
+             && (INTVAL (XEXP (XEXP (varop, 0), 1))
+                 >= (GET_MODE_BITSIZE (GET_MODE (XEXP (varop, 0))) - GET_MODE_BITSIZE (varop))))
+           {
+             rtx varop_inner = XEXP (varop, 0);
+
+             varop_inner = gen_rtx_combine (LSHIFTRT,
+                                            GET_MODE (varop_inner),
+                                            XEXP (varop_inner, 0),
+                                            GEN_INT (count + INTVAL (XEXP (varop_inner, 1))));
+             varop = gen_rtx_combine (TRUNCATE, GET_MODE (varop),
+                                      varop_inner);
+             count = 0;
+             continue;
+           }
+         break;
          
        default:
          break;