No functional changes.

2016-07-11  Uros Bizjak  <ubiz...@gmail.com>

    * config/i386/predicates.md (x86_64_immediate_operand) <case CONST>:
    Hoist common subexpressions.
    (x86_64_zext_immediate_operand) <case CONST>: Ditto.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 2c4cfe6..6854c37 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -205,7 +205,11 @@
            return false;
          if (!CONST_INT_P (op2))
            return false;
+
          offset = trunc_int_for_mode (INTVAL (op2), DImode);
+         if (trunc_int_for_mode (offset, SImode) != offset)
+           return false;
+
          switch (GET_CODE (op1))
            {
            case SYMBOL_REF:
@@ -224,16 +228,14 @@
              if ((ix86_cmodel == CM_SMALL
                   || (ix86_cmodel == CM_MEDIUM
                       && !SYMBOL_REF_FAR_ADDR_P (op1)))
-                 && offset < 16*1024*1024
-                 && trunc_int_for_mode (offset, SImode) == offset)
+                 && offset < 16*1024*1024)
                return true;
              /* For CM_KERNEL we know that all object resist in the
                 negative half of 32bits address space.  We may not
                 accept negative offsets, since they may be just off
                 and we may accept pretty large positive ones.  */
              if (ix86_cmodel == CM_KERNEL
-                 && offset > 0
-                 && trunc_int_for_mode (offset, SImode) == offset)
+                 && offset > 0)
                return true;
              break;
 
@@ -241,12 +243,10 @@
              /* These conditions are similar to SYMBOL_REF ones, just the
                 constraints for code models differ.  */
              if ((ix86_cmodel == CM_SMALL || ix86_cmodel == CM_MEDIUM)
-                 && offset < 16*1024*1024
-                 && trunc_int_for_mode (offset, SImode) == offset)
+                 && offset < 16*1024*1024)
                return true;
              if (ix86_cmodel == CM_KERNEL
-                 && offset > 0
-                 && trunc_int_for_mode (offset, SImode) == offset)
+                 && offset > 0)
                return true;
              break;
 
@@ -255,8 +255,7 @@
                {
                case UNSPEC_DTPOFF:
                case UNSPEC_NTPOFF:
-                 if (trunc_int_for_mode (offset, SImode) == offset)
-                   return true;
+                 return true;
                }
              break;
 
@@ -307,9 +306,17 @@
        {
          rtx op1 = XEXP (XEXP (op, 0), 0);
          rtx op2 = XEXP (XEXP (op, 0), 1);
+         HOST_WIDE_INT offset;
 
          if (ix86_cmodel == CM_LARGE)
            return false;
+         if (!CONST_INT_P (op2))
+           return false;
+
+         offset = trunc_int_for_mode (INTVAL (op2), DImode);
+         if (trunc_int_for_mode (offset, SImode) != offset)
+           return false;
+
          switch (GET_CODE (op1))
            {
            case SYMBOL_REF:
@@ -328,9 +335,7 @@
              if ((ix86_cmodel == CM_SMALL
                   || (ix86_cmodel == CM_MEDIUM
                       && !SYMBOL_REF_FAR_ADDR_P (op1)))
-                 && CONST_INT_P (op2)
-                 && trunc_int_for_mode (INTVAL (op2), DImode) > -0x10000
-                 && trunc_int_for_mode (INTVAL (op2), SImode) == INTVAL (op2))
+                 && offset > -0x10000)
                return true;
              /* ??? For the kernel, we may accept adjustment of
                 -0x10000000, since we know that it will just convert
@@ -342,9 +347,7 @@
              /* These conditions are similar to SYMBOL_REF ones, just the
                 constraints for code models differ.  */
              if ((ix86_cmodel == CM_SMALL || ix86_cmodel == CM_MEDIUM)
-                 && CONST_INT_P (op2)
-                 && trunc_int_for_mode (INTVAL (op2), DImode) > -0x10000
-                 && trunc_int_for_mode (INTVAL (op2), SImode) == INTVAL (op2))
+                 && offset > -0x10000)
                return true;
              break;
 

Reply via email to