]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/simplify-rtx.c
Merge from trunk.
[thirdparty/gcc.git] / gcc / simplify-rtx.c
index 3757ff7592e11218874fe9a9c347af3e89a5aba6..44b500a38bbc9344eca351051effdb02383868da 100644 (file)
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "rtl.h"
 #include "tree.h"
+#include "varasm.h"
 #include "tm_p.h"
 #include "regs.h"
 #include "hard-reg-set.h"
@@ -321,7 +322,7 @@ delegitimize_mem_from_attrs (rtx x)
              {
                offset += bitpos / BITS_PER_UNIT;
                if (toffset)
-                 offset += tree_to_hwi (toffset);
+                 offset += tree_to_shwi (toffset);
              }
            break;
          }
@@ -1619,7 +1620,7 @@ simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode,
             a dangerous assumption as many times CONST_INTs are
             created and used with garbage in the bits outside of the
             precision of the implied mode of the const_int.  */
-         op_mode = mode_for_size (MAX_BITSIZE_MODE_ANY_INT, MODE_INT, 0);
+         op_mode = MAX_MODE_INT;
        }
 
       real_from_integer (&d, mode, std::make_pair (op, op_mode), SIGNED);
@@ -1637,7 +1638,7 @@ simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode,
             a dangerous assumption as many times CONST_INTs are
             created and used with garbage in the bits outside of the
             precision of the implied mode of the const_int.  */
-         op_mode = mode_for_size (MAX_BITSIZE_MODE_ANY_INT, MODE_INT, 0);
+         op_mode = MAX_MODE_INT;
        }
 
       real_from_integer (&d, mode, std::make_pair (op, op_mode), UNSIGNED);
@@ -1686,7 +1687,7 @@ simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode,
        case CLRSB:
          result = wi::shwi (wi::clrsb (op0), mode);
          break;
-         
+
        case CTZ:
          result = wi::shwi (wi::ctz (op0), mode);
          break;
@@ -2223,7 +2224,7 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
          else if (GET_CODE (rhs) == MULT
                   && CONST_INT_P (XEXP (rhs, 1)))
            {
-             negcoeff1 = -wide_int (std::make_pair (XEXP (rhs, 1), mode));
+             negcoeff1 = wi::neg (std::make_pair (XEXP (rhs, 1), mode));
              rhs = XEXP (rhs, 0);
            }
          else if (GET_CODE (rhs) == ASHIFT
@@ -2399,7 +2400,7 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
       if (CONST_SCALAR_INT_P (trueop1))
        {
          val = wi::exact_log2 (std::make_pair (trueop1, mode));
-         if (val >= 0 && val < GET_MODE_BITSIZE (mode))
+         if (val >= 0)
            return simplify_gen_binary (ASHIFT, mode, op0, GEN_INT (val));
        }
 
@@ -3703,7 +3704,6 @@ simplify_const_binary_operation (enum rtx_code code, enum machine_mode mode,
     {
       wide_int result;
       bool overflow;
-      unsigned int bitsize = GET_MODE_BITSIZE (mode);
       rtx_mode_t pop0 = std::make_pair (op0, mode);
       rtx_mode_t pop1 = std::make_pair (op1, mode); 
 
@@ -3785,36 +3785,46 @@ simplify_const_binary_operation (enum rtx_code code, enum machine_mode mode,
        case LSHIFTRT:
        case ASHIFTRT:
        case ASHIFT:
-       case ROTATE:
-       case ROTATERT:
          {
            wide_int wop1 = pop1;
-           if (wi::neg_p (wop1))
-             return NULL_RTX;
-
            if (SHIFT_COUNT_TRUNCATED)
              wop1 = wi::umod_trunc (wop1, width);
+           else if (wi::geu_p (wop1, width))
+             return NULL_RTX;
 
            switch (code)
              {
              case LSHIFTRT:
-               result = wi::lrshift (pop0, wop1, bitsize);
+               result = wi::lrshift (pop0, wop1);
                break;
                
              case ASHIFTRT:
-               result = wi::arshift (pop0, wop1, bitsize);
+               result = wi::arshift (pop0, wop1);
                break;
                
              case ASHIFT:
-               result = wi::lshift (pop0, wop1, bitsize);
+               result = wi::lshift (pop0, wop1);
                break;
                
+             default:
+               gcc_unreachable ();
+             }
+           break;
+         }
+       case ROTATE:
+       case ROTATERT:
+         {
+           if (wi::neg_p (pop1))
+             return NULL_RTX;
+
+           switch (code)
+             {
              case ROTATE:
-               result = wi::lrotate (pop0, wop1);
+               result = wi::lrotate (pop0, pop1);
                break;
                
              case ROTATERT:
-               result = wi::rrotate (pop0, wop1);
+               result = wi::rrotate (pop0, pop1);
                break;
 
              default:
@@ -5122,7 +5132,7 @@ simplify_immed_subreg (enum machine_mode outermode, rtx op,
     value_bit = 8,
     value_mask = (1 << value_bit) - 1
   };
-  unsigned char value[MAX_BITSIZE_MODE_ANY_MODE/value_bit];
+  unsigned char value[MAX_BITSIZE_MODE_ANY_MODE / value_bit];
   int value_start;
   int i;
   int elem;