+2015-12-11  Dominik Vogt  <vogt@linux.vnet.ibm.com>
+
+       * config/s390/s390.c (s390_rtx_costs)
+       (s390_cannot_force_const_mem, legitimate_pic_operand_p)
+       (s390_preferred_reload_class, s390_reload_symref_address)
+       (legitimate_reload_constant_p, print_operand): Wide int support.
+       * config/s390/predicates.md ("const0_operand", "constm1_operand")
+       ("consttable_operand"): Likewise.
+       ("larl_operand"): Add a comment.
+       * config/s390/s390.h (TARGET_SUPPORTS_WIDE_INT): Enable wide int
+       support.
+
 2015-12-11  Nathan Sidwell  <nathan@acm.org>
 
        * config/nvptx/nvptx.h (TARGET_SUPPORTS_WIDE_INT): Define.
        ("*setmem_long_and_31z"): New define_insn.
        ("setmem_long_<P:mode>"): New expanders.
        * (<modesize>): New mode attribute
-       
+
 2015-12-11  Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
        * config/s390/s390.md ("movstr", "*movstr"): Fix warning.
 
 
 ;; Return true if OP a const 0 operand (int/float/vector).
 (define_predicate "const0_operand"
-  (and (match_code "const_int,const_double,const_vector")
+  (and (match_code "const_int,const_wide_int,const_double,const_vector")
        (match_test "op == CONST0_RTX (mode)")))
 
 ;; Return true if OP an all ones operand (int/float/vector).
 (define_predicate "constm1_operand"
-  (and (match_code "const_int, const_double,const_vector")
+  (and (match_code "const_int,const_wide_int,const_double,const_vector")
        (match_test "op == CONSTM1_RTX (mode)")))
 
 ;; Return true if OP is a 4 bit mask operand
 ;; Return true if OP is constant.
 
 (define_special_predicate "consttable_operand"
-  (and (match_code "symbol_ref, label_ref, const, const_int, const_double, const_vector")
+  (and (match_code "symbol_ref, label_ref, const, const_int, const_wide_int, const_double, const_vector")
        (match_test "CONSTANT_P (op)")))
 
 ;; Return true if OP is a valid S-type operand.
 ;;  Return true if OP a valid operand for the LARL instruction.
 
 (define_predicate "larl_operand"
+; Note: Although CONST_INT and CONST_DOUBLE are not handled in this predicate,
+; at least one of them needs to appear or otherwise safe_predicate_mode will
+; assume that a VOIDmode LABEL_REF is not accepted either (see genrecog.c).
   (match_code "label_ref, symbol_ref, const, const_int, const_double")
 {
   /* Allow labels and local symbols.  */
 
 {
   int bit0, bit1;
 
-  /* ??? Fixme: should work on CONST_DOUBLE as well.  */
+  /* ??? Fixme: should work on CONST_WIDE_INT as well.  */
   if (GET_CODE (op1) != CONST_INT || GET_CODE (op2) != CONST_INT)
     return VOIDmode;
 
     case LABEL_REF:
     case SYMBOL_REF:
     case CONST_DOUBLE:
+    case CONST_WIDE_INT:
     case MEM:
       *total = 0;
       return true;
 
 /* Return true if OP is a legitimate general operand when
    generating PIC code.  It is given that flag_pic is on
-   and that OP satisfies CONSTANT_P or is a CONST_DOUBLE.  */
+   and that OP satisfies CONSTANT_P.  */
 
 int
 legitimate_pic_operand_p (rtx op)
 }
 
 /* Returns true if the constant value OP is a legitimate general operand.
-   It is given that OP satisfies CONSTANT_P or is a CONST_DOUBLE.  */
+   It is given that OP satisfies CONSTANT_P.  */
 
 static bool
 s390_legitimate_constant_p (machine_mode mode, rtx op)
     {
     case CONST_INT:
     case CONST_DOUBLE:
+    case CONST_WIDE_INT:
     case CONST_VECTOR:
       /* Accept all non-symbolic constants.  */
       return false;
     return true;
 
   /* Accept double-word operands that can be split.  */
-  if (GET_CODE (op) == CONST_INT
-      && trunc_int_for_mode (INTVAL (op), word_mode) != INTVAL (op))
+  if (GET_CODE (op) == CONST_WIDE_INT
+      || (GET_CODE (op) == CONST_INT
+         && trunc_int_for_mode (INTVAL (op), word_mode) != INTVAL (op)))
     {
       machine_mode dword_mode = word_mode == SImode ? DImode : TImode;
       rtx hi = operand_subword (op, 0, 0, dword_mode);
       case CONST_VECTOR:
       case CONST_DOUBLE:
       case CONST_INT:
+      case CONST_WIDE_INT:
        if (reg_class_subset_p (GENERAL_REGS, rclass)
            && legitimate_reload_constant_p (op))
          return GENERAL_REGS;
   /* Reload might have pulled a constant out of the literal pool.
      Force it back in.  */
   if (CONST_INT_P (mem) || GET_CODE (mem) == CONST_DOUBLE
+      || GET_CODE (mem) == CONST_WIDE_INT
       || GET_CODE (mem) == CONST_VECTOR
       || GET_CODE (mem) == CONST)
     mem = force_const_mem (GET_MODE (reg), mem);
       fprintf (file, HOST_WIDE_INT_PRINT_DEC, ival);
       break;
 
-    case CONST_DOUBLE:
-      gcc_assert (GET_MODE (x) == VOIDmode);
+    case CONST_WIDE_INT:
       if (code == 'b')
-        fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (x) & 0xff);
+        fprintf (file, HOST_WIDE_INT_PRINT_DEC,
+                CONST_WIDE_INT_ELT (x, 0) & 0xff);
       else if (code == 'x')
-        fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (x) & 0xffff);
+        fprintf (file, HOST_WIDE_INT_PRINT_DEC,
+                CONST_WIDE_INT_ELT (x, 0) & 0xffff);
       else if (code == 'h')
         fprintf (file, HOST_WIDE_INT_PRINT_DEC,
-                ((CONST_DOUBLE_LOW (x) & 0xffff) ^ 0x8000) - 0x8000);
+                ((CONST_WIDE_INT_ELT (x, 0) & 0xffff) ^ 0x8000) - 0x8000);
       else
        {
          if (code == 0)
 
 #define SWITCHABLE_TARGET 1
 #endif
 
+#define TARGET_SUPPORTS_WIDE_INT 1
+
 /* Use the ABI introduced with IBM z13:
    - pass vector arguments <= 16 bytes in VRs
    - align *all* vector types to 8 bytes  */