Patchwork patch to fix constant math - third small patch

login
register
mail settings
Submitter Kenneth Zadeck
Date Oct. 8, 2012, 11:36 a.m.
Message ID <5072BAD1.5080701@naturalbridge.com>
Download mbox | patch
Permalink /patch/189998/
State New
Headers show

Comments

Kenneth Zadeck - Oct. 8, 2012, 11:36 a.m.
yes, my bad.   here it is with the patches.
On 10/06/2012 11:55 AM, Kenneth Zadeck wrote:
> This is the third patch in the series of patches to fix constant math.
> this one changes some predicates at the rtl level to use the new 
> predicate CONST_SCALAR_INT_P.
> I did not include a few that were tightly intertwined with other changes.
>
> Not all of these changes are strictly mechanical.   Richard, when 
> reviewing this had me make additional changes to remove what he 
> thought were latent bugs at the rtl level.   However, it appears that 
> the bugs were not latent.    I do not know what is going on here but i 
> am smart enough to not look a gift horse in the mouth.
>
> All of this was done on the same machine with no changes and identical 
> configs.  It is an x86-64 with ubuntu 12-4.
>
> ok for commit?
>
> in the logs below, gbBaseline is a trunk from friday and the gbWide is 
> the same revision but with my patches.  Some of this like 
> gfortran.dg/pr32627 is obviously flutter, but the rest does not appear 
> to be.
>
> =========
> heracles:~/gcc(13) gccBaseline/contrib/compare_tests 
> gbBaseline/gcc/testsuite/gcc/gcc.log gbWide/gcc/testsuite/gcc/gcc.log
> New tests that PASS:
>
> gcc.dg/builtins-85.c scan-assembler mysnprintf
> gcc.dg/builtins-85.c scan-assembler-not __chk_fail
> gcc.dg/builtins-85.c (test for excess errors)
>
>
> heracles:~/gcc(14) gccBaseline/contrib/compare_tests 
> gbBaseline/gcc/testsuite/gfortran/gfortran.log 
> gbWide/gcc/testsuite/gfortran/gfortran.log
> New tests that PASS:
>
> gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer -funroll-loops (test 
> for excess errors)
> gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer  (test for excess 
> errors)
> gfortran.dg/pr32627.f03  -Os  (test for excess errors)
> gfortran.dg/pr32635.f  -O0  execution test
> gfortran.dg/pr32635.f  -O0  (test for excess errors)
> gfortran.dg/substr_6.f90  -O2  (test for excess errors)
>
> Old tests that passed, that have disappeared: (Eeek!)
>
> gfortran.dg/pr32627.f03  -O1  (test for excess errors)
> gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer -funroll-all-loops 
> -finline-functions  (test for excess errors)
> gfortran.dg/pr32627.f03  -O3 -g  (test for excess errors)
> gfortran.dg/substring_equivalence.f90  -O  (test for excess errors)
> Using /home/zadeck/gcc/gccBaseline/gcc/testsuite/config/default.exp as 
> tool-and-target-specific interface file.
>
>         === g++ Summary ===
>
> # of expected passes        49793
> # of expected failures        284
> # of unsupported tests        601
>
> runtest completed at Fri Oct  5 16:10:20 2012
> heracles:~/gcc(16) tail gbWide/gcc/testsuite/g++/g++.log Using 
> /usr/share/dejagnu/config/unix.exp as generic interface file for target.
> Using /home/zadeck/gcc/gccWide/gcc/testsuite/config/default.exp as 
> tool-and-target-specific interface file.
>
>         === g++ Summary ===
>
> # of expected passes        50472
> # of expected failures        284
> # of unsupported tests        613
>
> runtest completed at Fri Oct  5 19:51:50 2012
>
>
>
>
>
2012-10-6  Kenneth Zadeck <zadeck@naturalbridge.com>

	* rtl.h (CONST_SCALAR_INT_P): New macro.
   	* cfgexpand.c (expand_debug_locations): Changed to use
	CONST_SCALAR_INT_P macro.
	* combine.c (try_combine, subst, make_extraction,
	gen_lowpart_for_combine): Ditto.
	* cselib.c (entry_and_rtx_equal_p, rtx_equal_for_cselib_1): Ditto.
	* dwarf2out.c (loc_descriptor): Ditto.
	* emit-rtl.c (gen_lowpart_common): Ditto.
	* ira-costs.c (record_reg_classes, record_address_regs): Ditto.
	* ira-lives.c (single_reg_class): Ditto.
	* recog.c (simplify_while_replacing, asm_operand_ok,
	constrain_operands): Ditto.
	* reload.c (find_reloads): Ditto.
	* simplify-rtx.c (simplify_unary_operation_1,
	simplify_const_unary_operation, simplify_binary_operation_1,
	simplify_const_binary_operation, simplify_relational_operation_1,
	simplify_subreg): Ditto.
Richard Guenther - Oct. 8, 2012, 12:11 p.m.
On Mon, Oct 8, 2012 at 1:36 PM, Kenneth Zadeck <zadeck@naturalbridge.com> wrote:
> yes, my bad.   here it is with the patches.

Just for the record, ok!

Thanks,
Richard.

> On 10/06/2012 11:55 AM, Kenneth Zadeck wrote:
>>
>> This is the third patch in the series of patches to fix constant math.
>> this one changes some predicates at the rtl level to use the new predicate
>> CONST_SCALAR_INT_P.
>> I did not include a few that were tightly intertwined with other changes.
>>
>> Not all of these changes are strictly mechanical.   Richard, when
>> reviewing this had me make additional changes to remove what he thought were
>> latent bugs at the rtl level.   However, it appears that the bugs were not
>> latent.    I do not know what is going on here but i am smart enough to not
>> look a gift horse in the mouth.
>>
>> All of this was done on the same machine with no changes and identical
>> configs.  It is an x86-64 with ubuntu 12-4.
>>
>> ok for commit?
>>
>> in the logs below, gbBaseline is a trunk from friday and the gbWide is the
>> same revision but with my patches.  Some of this like gfortran.dg/pr32627 is
>> obviously flutter, but the rest does not appear to be.
>>
>> =========
>> heracles:~/gcc(13) gccBaseline/contrib/compare_tests
>> gbBaseline/gcc/testsuite/gcc/gcc.log gbWide/gcc/testsuite/gcc/gcc.log
>> New tests that PASS:
>>
>> gcc.dg/builtins-85.c scan-assembler mysnprintf
>> gcc.dg/builtins-85.c scan-assembler-not __chk_fail
>> gcc.dg/builtins-85.c (test for excess errors)
>>
>>
>> heracles:~/gcc(14) gccBaseline/contrib/compare_tests
>> gbBaseline/gcc/testsuite/gfortran/gfortran.log
>> gbWide/gcc/testsuite/gfortran/gfortran.log
>> New tests that PASS:
>>
>> gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer -funroll-loops (test for
>> excess errors)
>> gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer  (test for excess
>> errors)
>> gfortran.dg/pr32627.f03  -Os  (test for excess errors)
>> gfortran.dg/pr32635.f  -O0  execution test
>> gfortran.dg/pr32635.f  -O0  (test for excess errors)
>> gfortran.dg/substr_6.f90  -O2  (test for excess errors)
>>
>> Old tests that passed, that have disappeared: (Eeek!)
>>
>> gfortran.dg/pr32627.f03  -O1  (test for excess errors)
>> gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer -funroll-all-loops
>> -finline-functions  (test for excess errors)
>> gfortran.dg/pr32627.f03  -O3 -g  (test for excess errors)
>> gfortran.dg/substring_equivalence.f90  -O  (test for excess errors)
>> Using /home/zadeck/gcc/gccBaseline/gcc/testsuite/config/default.exp as
>> tool-and-target-specific interface file.
>>
>>         === g++ Summary ===
>>
>> # of expected passes        49793
>> # of expected failures        284
>> # of unsupported tests        601
>>
>> runtest completed at Fri Oct  5 16:10:20 2012
>> heracles:~/gcc(16) tail gbWide/gcc/testsuite/g++/g++.log Using
>> /usr/share/dejagnu/config/unix.exp as generic interface file for target.
>> Using /home/zadeck/gcc/gccWide/gcc/testsuite/config/default.exp as
>> tool-and-target-specific interface file.
>>
>>         === g++ Summary ===
>>
>> # of expected passes        50472
>> # of expected failures        284
>> # of unsupported tests        613
>>
>> runtest completed at Fri Oct  5 19:51:50 2012
>>
>>
>>
>>
>>
>
Richard Sandiford - Oct. 8, 2012, 7:42 p.m.
Kenneth Zadeck <zadeck@naturalbridge.com> writes:
> diff --git a/gcc/combine.c b/gcc/combine.c
> index 4e0a579..b531305 100644
> --- a/gcc/combine.c
> +++ b/gcc/combine.c
> @@ -2617,16 +2617,19 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *new_direct_jump_p,
>       constant.  */
>    if (i1 == 0
>        && (temp = single_set (i2)) != 0
> -      && (CONST_INT_P (SET_SRC (temp))
> -	  || CONST_DOUBLE_AS_INT_P (SET_SRC (temp)))
> +      && CONST_SCALAR_INT_P (SET_SRC (temp))
>        && GET_CODE (PATTERN (i3)) == SET
> -      && (CONST_INT_P (SET_SRC (PATTERN (i3)))
> -	  || CONST_DOUBLE_AS_INT_P (SET_SRC (PATTERN (i3))))
> +      && CONST_SCALAR_INT_P (SET_SRC (PATTERN (i3)))
>        && reg_subword_p (SET_DEST (PATTERN (i3)), SET_DEST (temp)))
>      {
>        rtx dest = SET_DEST (PATTERN (i3));
>        int offset = -1;
>        int width = 0;
> +      
> +      /* There are not explicit tests to make sure that this is not a
> +	 float, but there is code here that would not be correct if it
> +	 was.  */
> +      gcc_assert (GET_MODE_CLASS (GET_MODE (SET_SRC (temp))) != MODE_FLOAT);

No need for this assert: CONST_SCALAR_INT_P (SET_SRC (temp)) should cover it.

> @@ -1009,9 +1007,7 @@ rtx_equal_for_cselib_1 (rtx x, rtx y, enum machine_mode memmode)
>  static rtx
>  wrap_constant (enum machine_mode mode, rtx x)
>  {
> -  if (!CONST_INT_P (x) 
> -      && GET_CODE (x) != CONST_FIXED
> -      && !CONST_DOUBLE_AS_INT_P (x))
> +  if ((!CONST_SCALAR_INT_P (x)) && GET_CODE (x) != CONST_FIXED)

Redundant brackets.

Looks good to me otherwise, thanks.

Richard

Patch

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 299150e..0404605 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3633,9 +3633,8 @@  expand_debug_locations (void)
 
 	    gcc_assert (mode == GET_MODE (val)
 			|| (GET_MODE (val) == VOIDmode
-			    && (CONST_INT_P (val)
+			    && (CONST_SCALAR_INT_P (val)
 				|| GET_CODE (val) == CONST_FIXED
-				|| CONST_DOUBLE_AS_INT_P (val) 
 				|| GET_CODE (val) == LABEL_REF)));
 	  }
 
diff --git a/gcc/combine.c b/gcc/combine.c
index 4e0a579..b531305 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -2617,16 +2617,19 @@  try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *new_direct_jump_p,
      constant.  */
   if (i1 == 0
       && (temp = single_set (i2)) != 0
-      && (CONST_INT_P (SET_SRC (temp))
-	  || CONST_DOUBLE_AS_INT_P (SET_SRC (temp)))
+      && CONST_SCALAR_INT_P (SET_SRC (temp))
       && GET_CODE (PATTERN (i3)) == SET
-      && (CONST_INT_P (SET_SRC (PATTERN (i3)))
-	  || CONST_DOUBLE_AS_INT_P (SET_SRC (PATTERN (i3))))
+      && CONST_SCALAR_INT_P (SET_SRC (PATTERN (i3)))
       && reg_subword_p (SET_DEST (PATTERN (i3)), SET_DEST (temp)))
     {
       rtx dest = SET_DEST (PATTERN (i3));
       int offset = -1;
       int width = 0;
+      
+      /* There are not explicit tests to make sure that this is not a
+	 float, but there is code here that would not be correct if it
+	 was.  */
+      gcc_assert (GET_MODE_CLASS (GET_MODE (SET_SRC (temp))) != MODE_FLOAT);
 
       if (GET_CODE (dest) == ZERO_EXTRACT)
 	{
@@ -5102,8 +5105,7 @@  subst (rtx x, rtx from, rtx to, int in_dest, int in_cond, int unique_copy)
 	      if (GET_CODE (new_rtx) == CLOBBER && XEXP (new_rtx, 0) == const0_rtx)
 		return new_rtx;
 
-	      if (GET_CODE (x) == SUBREG
-		  && (CONST_INT_P (new_rtx) || CONST_DOUBLE_AS_INT_P (new_rtx)))
+	      if (GET_CODE (x) == SUBREG && CONST_SCALAR_INT_P (new_rtx))
 		{
 		  enum machine_mode mode = GET_MODE (x);
 
@@ -7133,7 +7135,7 @@  make_extraction (enum machine_mode mode, rtx inner, HOST_WIDE_INT pos,
       if (mode == tmode)
 	return new_rtx;
 
-      if (CONST_INT_P (new_rtx) || CONST_DOUBLE_AS_INT_P (new_rtx))
+      if (CONST_SCALAR_INT_P (new_rtx))
 	return simplify_unary_operation (unsignedp ? ZERO_EXTEND : SIGN_EXTEND,
 					 mode, new_rtx, tmode);
 
@@ -10672,8 +10674,7 @@  gen_lowpart_for_combine (enum machine_mode omode, rtx x)
   /* We can only support MODE being wider than a word if X is a
      constant integer or has a mode the same size.  */
   if (GET_MODE_SIZE (omode) > UNITS_PER_WORD
-      && ! ((CONST_INT_P (x) || CONST_DOUBLE_AS_INT_P (x))
-	    || isize == osize))
+      && ! (CONST_SCALAR_INT_P (x) || isize == osize))
     goto fail;
 
   /* X might be a paradoxical (subreg (mem)).  In that case, gen_lowpart
diff --git a/gcc/cselib.c b/gcc/cselib.c
index e7c4221..e6550a3 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -534,17 +534,15 @@  entry_and_rtx_equal_p (const void *entry, const void *x_arg)
   rtx x = CONST_CAST_RTX ((const_rtx)x_arg);
   enum machine_mode mode = GET_MODE (x);
 
-  gcc_assert (!CONST_INT_P (x) && GET_CODE (x) != CONST_FIXED
-	      && (mode != VOIDmode || GET_CODE (x) != CONST_DOUBLE));
+  gcc_assert (!CONST_SCALAR_INT_P (x) && GET_CODE (x) != CONST_FIXED);
 
   if (mode != GET_MODE (v->val_rtx))
     return 0;
 
   /* Unwrap X if necessary.  */
   if (GET_CODE (x) == CONST
-      && (CONST_INT_P (XEXP (x, 0))
-	  || GET_CODE (XEXP (x, 0)) == CONST_FIXED
-	  || GET_CODE (XEXP (x, 0)) == CONST_DOUBLE))
+      && (CONST_SCALAR_INT_P (XEXP (x, 0))
+	  || GET_CODE (XEXP (x, 0)) == CONST_FIXED))
     x = XEXP (x, 0);
 
   /* We don't guarantee that distinct rtx's have different hash values,
@@ -1009,9 +1007,7 @@  rtx_equal_for_cselib_1 (rtx x, rtx y, enum machine_mode memmode)
 static rtx
 wrap_constant (enum machine_mode mode, rtx x)
 {
-  if (!CONST_INT_P (x) 
-      && GET_CODE (x) != CONST_FIXED
-      && !CONST_DOUBLE_AS_INT_P (x))
+  if ((!CONST_SCALAR_INT_P (x)) && GET_CODE (x) != CONST_FIXED)
     return x;
   gcc_assert (mode != VOIDmode);
   return gen_rtx_CONST (mode, x);
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 95fc130..98c88f7 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -12351,8 +12351,8 @@  loc_descriptor (rtx rtl, enum machine_mode mode,
 
     case CONST:
       if (mode == VOIDmode
-	  || GET_CODE (XEXP (rtl, 0)) == CONST_INT
-	  || GET_CODE (XEXP (rtl, 0)) == CONST_DOUBLE
+	  || CONST_SCALAR_INT_P (XEXP (rtl, 0))
+	  || CONST_DOUBLE_AS_FLOAT_P (XEXP (rtl, 0))
 	  || GET_CODE (XEXP (rtl, 0)) == CONST_VECTOR)
 	{
 	  loc_result = loc_descriptor (XEXP (rtl, 0), mode, initialized);
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index ee6ae22..bd6fc26 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -1244,7 +1244,7 @@  gen_lowpart_common (enum machine_mode mode, rtx x)
     }
   else if (GET_CODE (x) == SUBREG || REG_P (x)
 	   || GET_CODE (x) == CONCAT || GET_CODE (x) == CONST_VECTOR
-	   || CONST_DOUBLE_P (x) || CONST_INT_P (x))
+	   || CONST_DOUBLE_AS_FLOAT_P (x) || CONST_SCALAR_INT_P (x))
     return simplify_gen_subreg (mode, x, innermode, offset);
 
   /* Otherwise, we can't do this.  */
diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c
index 0c59b03..50ffaea 100644
--- a/gcc/ira-costs.c
+++ b/gcc/ira-costs.c
@@ -667,7 +667,7 @@  record_reg_classes (int n_alts, int n_ops, rtx *ops,
 		  break;
 
 		case 's':
-		  if (CONST_INT_P (op) || CONST_DOUBLE_AS_INT_P (op)) 
+		  if (CONST_SCALAR_INT_P (op)) 
 		    break;
 
 		case 'i':
@@ -677,7 +677,7 @@  record_reg_classes (int n_alts, int n_ops, rtx *ops,
 		  break;
 
 		case 'n':
-		  if (CONST_INT_P (op) || CONST_DOUBLE_AS_INT_P (op)) 
+		  if (CONST_SCALAR_INT_P (op)) 
 		    win = 1;
 		  break;
 
@@ -1068,7 +1068,7 @@  record_address_regs (enum machine_mode mode, addr_space_t as, rtx x,
 
 	/* If the second operand is a constant integer, it doesn't
 	   change what class the first operand must be.  */
-	else if (code1 == CONST_INT || code1 == CONST_DOUBLE)
+	else if (CONST_SCALAR_INT_P (arg1))
 	  record_address_regs (mode, as, arg0, context, PLUS, code1, scale);
 	/* If the second operand is a symbolic constant, the first
 	   operand must be an index register.  */
diff --git a/gcc/ira-lives.c b/gcc/ira-lives.c
index 853832e..a7a2332 100644
--- a/gcc/ira-lives.c
+++ b/gcc/ira-lives.c
@@ -779,22 +779,16 @@  single_reg_class (const char *constraints, rtx op, rtx equiv_const)
 	  break;
 
 	case 'n':
-	  if (CONST_INT_P (op)
-	      || CONST_DOUBLE_AS_INT_P (op)
-	      || (equiv_const != NULL_RTX
-		  && (CONST_INT_P (equiv_const)
-		      || CONST_DOUBLE_AS_INT_P (equiv_const))))
+	  if (CONST_SCALAR_INT_P (op)
+	      || (equiv_const != NULL_RTX && CONST_SCALAR_INT_P (equiv_const)))
 	    return NO_REGS;
 	  break;
 
 	case 's':
-	  if ((CONSTANT_P (op) 
-	       && !CONST_INT_P (op) 
-	       && !CONST_DOUBLE_AS_INT_P (op))
+	  if ((CONSTANT_P (op) && !CONST_SCALAR_INT_P (op))
 	      || (equiv_const != NULL_RTX
 		  && CONSTANT_P (equiv_const)
-		  && !CONST_INT_P (equiv_const)
-		  && !CONST_DOUBLE_AS_INT_P (equiv_const)))
+		  && !CONST_SCALAR_INT_P (equiv_const)))
 	    return NO_REGS;
 	  break;
 
diff --git a/gcc/recog.c b/gcc/recog.c
index f28b021..a53f034 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -586,8 +586,7 @@  simplify_while_replacing (rtx *loc, rtx to, rtx object,
 			 (PLUS, GET_MODE (x), XEXP (x, 0), XEXP (x, 1)), 1);
       break;
     case MINUS:
-      if (CONST_INT_P (XEXP (x, 1))
-	  || CONST_DOUBLE_AS_INT_P (XEXP (x, 1)))
+      if (CONST_SCALAR_INT_P (XEXP (x, 1)))
 	validate_change (object, loc,
 			 simplify_gen_binary
 			 (PLUS, GET_MODE (x), XEXP (x, 0),
@@ -1726,7 +1725,7 @@  asm_operand_ok (rtx op, const char *constraint, const char **constraints)
 	  break;
 
 	case 's':
-	  if (CONST_INT_P (op) || CONST_DOUBLE_AS_INT_P (op))
+	  if (CONST_SCALAR_INT_P (op))
 	    break;
 	  /* Fall through.  */
 
@@ -1736,7 +1735,7 @@  asm_operand_ok (rtx op, const char *constraint, const char **constraints)
 	  break;
 
 	case 'n':
-	  if (CONST_INT_P (op) || CONST_DOUBLE_AS_INT_P (op))
+	  if (CONST_SCALAR_INT_P (op))
 	    result = 1;
 	  break;
 
@@ -2591,7 +2590,7 @@  constrain_operands (int strict)
 		break;
 
 	      case 's':
-		if (CONST_INT_P (op) || CONST_DOUBLE_AS_INT_P (op))
+		if (CONST_SCALAR_INT_P (op))
 		  break;
 	      case 'i':
 		if (CONSTANT_P (op))
@@ -2599,7 +2598,7 @@  constrain_operands (int strict)
 		break;
 
 	      case 'n':
-		if (CONST_INT_P (op) || CONST_DOUBLE_AS_INT_P (op))
+		if (CONST_SCALAR_INT_P (op))
 		  win = 1;
 		break;
 
diff --git a/gcc/reload.c b/gcc/reload.c
index 2e41ed6..36197c0 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -3437,7 +3437,7 @@  find_reloads (rtx insn, int replace, int ind_levels, int live_known,
 		    break;
 
 		  case 's':
-		    if (CONST_INT_P (operand) || CONST_DOUBLE_AS_INT_P (operand))
+		    if (CONST_SCALAR_INT_P (operand))
 		      break;
 		  case 'i':
 		    if (CONSTANT_P (operand)
@@ -3446,7 +3446,7 @@  find_reloads (rtx insn, int replace, int ind_levels, int live_known,
 		    break;
 
 		  case 'n':
-		    if (CONST_INT_P (operand) || CONST_DOUBLE_AS_INT_P (operand))
+		    if (CONST_SCALAR_INT_P (operand))
 		      win = 1;
 		    break;
 
diff --git a/gcc/rtl.h b/gcc/rtl.h
index cd5d435..8c45e2e 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -430,6 +430,10 @@  struct GTY((variable_size)) rtvec_def {
 #define CONST_DOUBLE_AS_INT_P(X) \
   (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == VOIDmode)
 
+/* Predicate yielding true iff X is an rtx for a integer const.  */
+#define CONST_SCALAR_INT_P(X) \
+  (CONST_INT_P (X) || CONST_DOUBLE_AS_INT_P (X))
+
 /* Predicate yielding true iff X is an rtx for a double-int.  */
 #define CONST_DOUBLE_AS_FLOAT_P(X) \
   (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode)
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index acd4798..933c725 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -729,8 +729,8 @@  simplify_unary_operation_1 (enum rtx_code code, enum machine_mode mode, rtx op)
 	  && !HONOR_SIGN_DEPENDENT_ROUNDING (mode))
 	{
 	  /* (neg (plus A C)) is simplified to (minus -C A).  */
-	  if (CONST_INT_P (XEXP (op, 1))
-	      || CONST_DOUBLE_P (XEXP (op, 1)))
+	  if (CONST_SCALAR_INT_P (XEXP (op, 1))
+	      || CONST_DOUBLE_AS_FLOAT_P (XEXP (op, 1)))
 	    {
 	      temp = simplify_unary_operation (NEG, mode, XEXP (op, 1), mode);
 	      if (temp)
@@ -1284,7 +1284,7 @@  simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode,
 	  gcc_assert (GET_MODE_INNER (mode) == GET_MODE_INNER
 						(GET_MODE (op)));
       }
-      if (CONST_INT_P (op) || CONST_DOUBLE_P (op)
+      if (CONST_SCALAR_INT_P (op) || CONST_DOUBLE_AS_FLOAT_P (op)
 	  || GET_CODE (op) == CONST_VECTOR)
 	{
           int elt_size = GET_MODE_SIZE (GET_MODE_INNER (mode));
@@ -1337,7 +1337,7 @@  simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode,
      check the wrong mode (input vs. output) for a conversion operation,
      such as FIX.  At some point, this should be simplified.  */
 
-  if (code == FLOAT && (CONST_DOUBLE_AS_INT_P (op) || CONST_INT_P (op)))
+  if (code == FLOAT && CONST_SCALAR_INT_P (op))
     {
       HOST_WIDE_INT hv, lv;
       REAL_VALUE_TYPE d;
@@ -1351,8 +1351,7 @@  simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode,
       d = real_value_truncate (mode, d);
       return CONST_DOUBLE_FROM_REAL_VALUE (d, mode);
     }
-  else if (code == UNSIGNED_FLOAT
-	   && (CONST_DOUBLE_AS_INT_P (op) || CONST_INT_P (op)))
+  else if (code == UNSIGNED_FLOAT && CONST_SCALAR_INT_P (op))
     {
       HOST_WIDE_INT hv, lv;
       REAL_VALUE_TYPE d;
@@ -2043,10 +2042,9 @@  simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
 	}
 
       /* (plus (xor X C1) C2) is (xor X (C1^C2)) if C2 is signbit.  */
-      if ((CONST_INT_P (op1) || CONST_DOUBLE_AS_INT_P (op1))
+      if (CONST_SCALAR_INT_P (op1)
 	  && GET_CODE (op0) == XOR
-	  && (CONST_INT_P (XEXP (op0, 1))
-	      || CONST_DOUBLE_AS_INT_P (XEXP (op0, 1)))
+	  && CONST_SCALAR_INT_P (XEXP (op0, 1))
 	  && mode_signbit_p (mode, op1))
 	return simplify_gen_binary (XOR, mode, XEXP (op0, 0),
 				    simplify_gen_binary (XOR, mode, op1,
@@ -2226,7 +2224,7 @@  simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
 
       /* (-x - c) may be simplified as (-c - x).  */
       if (GET_CODE (op0) == NEG
-	  && (CONST_INT_P (op1) || CONST_DOUBLE_P (op1)))
+	  && (CONST_SCALAR_INT_P (op1) || CONST_DOUBLE_AS_FLOAT_P (op1)))
 	{
 	  tem = simplify_unary_operation (NEG, mode, op1, mode);
 	  if (tem)
@@ -2584,14 +2582,13 @@  simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
 	 return CONST0_RTX (mode);
 
       /* Canonicalize XOR of the most significant bit to PLUS.  */
-      if ((CONST_INT_P (op1) || CONST_DOUBLE_AS_INT_P (op1))
+      if (CONST_SCALAR_INT_P (op1)
 	  && mode_signbit_p (mode, op1))
 	return simplify_gen_binary (PLUS, mode, op0, op1);
       /* (xor (plus X C1) C2) is (xor X (C1^C2)) if C1 is signbit.  */
-      if ((CONST_INT_P (op1) || CONST_DOUBLE_AS_INT_P (op1))
+      if (CONST_SCALAR_INT_P (op1)
 	  && GET_CODE (op0) == PLUS
-	  && (CONST_INT_P (XEXP (op0, 1))
-	      || CONST_DOUBLE_AS_INT_P (XEXP (op0, 1)))
+	  && CONST_SCALAR_INT_P (XEXP (op0, 1))
 	  && mode_signbit_p (mode, XEXP (op0, 1)))
 	return simplify_gen_binary (XOR, mode, XEXP (op0, 0),
 				    simplify_gen_binary (XOR, mode, op1,
@@ -3356,9 +3353,11 @@  simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
 	  gcc_assert (GET_MODE_INNER (mode) == op1_mode);
 
 	if ((GET_CODE (trueop0) == CONST_VECTOR
-	     || CONST_INT_P (trueop0) || CONST_DOUBLE_P (trueop0))
+	     || CONST_SCALAR_INT_P (trueop0) 
+	     || CONST_DOUBLE_AS_FLOAT_P (trueop0))
 	    && (GET_CODE (trueop1) == CONST_VECTOR
-		|| CONST_INT_P (trueop1) || CONST_DOUBLE_P (trueop1)))
+		|| CONST_SCALAR_INT_P (trueop1) 
+		|| CONST_DOUBLE_AS_FLOAT_P (trueop1)))
 	  {
 	    int elt_size = GET_MODE_SIZE (GET_MODE_INNER (mode));
 	    unsigned n_elts = (GET_MODE_SIZE (mode) / elt_size);
@@ -3455,11 +3454,11 @@  simplify_const_binary_operation (enum rtx_code code, enum machine_mode mode,
 
   if (VECTOR_MODE_P (mode)
       && code == VEC_CONCAT
-      && (CONST_INT_P (op0)
+      && (CONST_SCALAR_INT_P (op0)
 	  || GET_CODE (op0) == CONST_FIXED
-	  || CONST_DOUBLE_P (op0))
-      && (CONST_INT_P (op1)
-	  || CONST_DOUBLE_P (op1)
+	  || CONST_DOUBLE_AS_FLOAT_P (op0))
+      && (CONST_SCALAR_INT_P (op1)
+	  || CONST_DOUBLE_AS_FLOAT_P (op1)
 	  || GET_CODE (op1) == CONST_FIXED))
     {
       unsigned n_elts = GET_MODE_NUNITS (mode);
@@ -4483,9 +4482,8 @@  simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode,
   /* (eq/ne (xor x C1) C2) simplifies to (eq/ne x (C1^C2)).  */
   if ((code == EQ || code == NE)
       && op0code == XOR
-      && (CONST_INT_P (op1) || CONST_DOUBLE_AS_INT_P (op1))
-      && (CONST_INT_P (XEXP (op0, 1))
-	  || CONST_DOUBLE_AS_INT_P (XEXP (op0, 1))))
+      && CONST_SCALAR_INT_P (op1)
+      && CONST_SCALAR_INT_P (XEXP (op0, 1)))
     return simplify_gen_relational (code, mode, cmp_mode, XEXP (op0, 0),
 				    simplify_gen_binary (XOR, cmp_mode,
 							 XEXP (op0, 1), op1));
@@ -5502,8 +5500,8 @@  simplify_subreg (enum machine_mode outermode, rtx op,
   if (outermode == innermode && !byte)
     return op;
 
-  if (CONST_INT_P (op)
-      || CONST_DOUBLE_P (op)
+  if (CONST_SCALAR_INT_P (op)
+      || CONST_DOUBLE_AS_FLOAT_P (op)
       || GET_CODE (op) == CONST_FIXED
       || GET_CODE (op) == CONST_VECTOR)
     return simplify_immed_subreg (outermode, op, innermode, byte);