OSDN Git Service

* gcc.c-torture/execute/align-3.c: Remove function addr check.
[pf3gnuchains/gcc-fork.git] / gcc / expmed.c
index 58b6a63..ad00973 100644 (file)
@@ -37,6 +37,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #include "real.h"
 #include "recog.h"
 #include "langhooks.h"
+#include "df.h"
 #include "target.h"
 
 static void store_fixed_bit_field (rtx, unsigned HOST_WIDE_INT,
@@ -150,7 +151,7 @@ init_expmed (void)
 
   PUT_CODE (&all.reg, REG);
   /* Avoid using hard regs in ways which may be unsupported.  */
-  REGNO (&all.reg) = LAST_VIRTUAL_REGISTER + 1;
+  SET_REGNO (&all.reg, LAST_VIRTUAL_REGISTER + 1);
 
   PUT_CODE (&all.plus, PLUS);
   XEXP (&all.plus, 0) = &all.reg;
@@ -4176,7 +4177,12 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode,
                HOST_WIDE_INT d = INTVAL (op1);
                unsigned HOST_WIDE_INT abs_d;
 
-               abs_d = d >= 0 ? d : - (unsigned HOST_WIDE_INT) d;
+               /* Since d might be INT_MIN, we have to cast to
+                  unsigned HOST_WIDE_INT before negating to avoid
+                  undefined signed overflow.  */
+               abs_d = (d >= 0
+                        ? (unsigned HOST_WIDE_INT) d
+                        : - (unsigned HOST_WIDE_INT) d);
 
                /* n rem d = n rem -d */
                if (rem_flag && d < 0)
@@ -5039,20 +5045,20 @@ make_tree (tree type, rtx x)
                          make_tree (type, XEXP (x, 1)));
 
     case LSHIFTRT:
-      t = lang_hooks.types.unsigned_type (type);
+      t = unsigned_type_for (type);
       return fold_convert (type, build2 (RSHIFT_EXPR, t,
                                         make_tree (t, XEXP (x, 0)),
                                         make_tree (type, XEXP (x, 1))));
 
     case ASHIFTRT:
-      t = lang_hooks.types.signed_type (type);
+      t = signed_type_for (type);
       return fold_convert (type, build2 (RSHIFT_EXPR, t,
                                         make_tree (t, XEXP (x, 0)),
                                         make_tree (type, XEXP (x, 1))));
 
     case DIV:
       if (TREE_CODE (type) != REAL_TYPE)
-       t = lang_hooks.types.signed_type (type);
+       t = signed_type_for (type);
       else
        t = type;
 
@@ -5060,7 +5066,7 @@ make_tree (tree type, rtx x)
                                         make_tree (t, XEXP (x, 0)),
                                         make_tree (t, XEXP (x, 1))));
     case UDIV:
-      t = lang_hooks.types.unsigned_type (type);
+      t = unsigned_type_for (type);
       return fold_convert (type, build2 (TRUNC_DIV_EXPR, t,
                                         make_tree (t, XEXP (x, 0)),
                                         make_tree (t, XEXP (x, 1))));