public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Use wi:: in canon_condition
@ 2015-04-28 13:56 Richard Sandiford
  2015-04-28 17:05 ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2015-04-28 13:56 UTC (permalink / raw)
  To: gcc-patches

Fix a simple case where we can generalise the CONST_INT handling to all
integer constants (CONST_DOUBLE or CONST_WIDE_INT).

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


gcc/
	* loop-iv.c (canon_condition): Generalize to all types of integer
	constant.

Index: gcc/loop-iv.c
===================================================================
--- gcc/loop-iv.c	2015-04-28 08:48:34.939851854 +0100
+++ gcc/loop-iv.c	2015-04-28 08:48:59.643540689 +0100
@@ -1729,39 +1729,42 @@ canon_condition (rtx cond)
     mode = GET_MODE (op1);
   gcc_assert (mode != VOIDmode);
 
-  if (CONST_INT_P (op1)
-      && GET_MODE_CLASS (mode) != MODE_CC
-      && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
+  if (CONST_SCALAR_INT_P (op1) && GET_MODE_CLASS (mode) != MODE_CC)
     {
-      HOST_WIDE_INT const_val = INTVAL (op1);
-      unsigned HOST_WIDE_INT uconst_val = const_val;
-      unsigned HOST_WIDE_INT max_val
-	= (unsigned HOST_WIDE_INT) GET_MODE_MASK (mode);
+      rtx_mode_t const_val (op1, mode);
 
       switch (code)
 	{
 	case LE:
-	  if ((unsigned HOST_WIDE_INT) const_val != max_val >> 1)
-	    code = LT, op1 = gen_int_mode (const_val + 1, GET_MODE (op0));
+	  if (wi::ne_p (const_val, wi::max_value (mode, SIGNED)))
+	    {
+	      code = LT;
+	      op1 = immed_wide_int_const (wi::add (const_val, 1),  mode);
+	    }
 	  break;
 
-	/* When cross-compiling, const_val might be sign-extended from
-	   BITS_PER_WORD to HOST_BITS_PER_WIDE_INT */
 	case GE:
-	  if ((HOST_WIDE_INT) (const_val & max_val)
-	      != (((HOST_WIDE_INT) 1
-		   << (GET_MODE_BITSIZE (GET_MODE (op0)) - 1))))
-	    code = GT, op1 = gen_int_mode (const_val - 1, mode);
+	  if (wi::ne_p (const_val, wi::min_value (mode, SIGNED)))
+	    {
+	      code = GT;
+	      op1 = immed_wide_int_const (wi::sub (const_val, 1), mode);
+	    }
 	  break;
 
 	case LEU:
-	  if (uconst_val < max_val)
-	    code = LTU, op1 = gen_int_mode (uconst_val + 1, mode);
+	  if (wi::ne_p (const_val, -1))
+	    {
+	      code = LTU;
+	      op1 = immed_wide_int_const (wi::add (const_val, 1), mode);
+	    }
 	  break;
 
 	case GEU:
-	  if (uconst_val != 0)
-	    code = GTU, op1 = gen_int_mode (uconst_val - 1, mode);
+	  if (wi::ne_p (const_val, 0))
+	    {
+	      code = GTU;
+	      op1 = immed_wide_int_const (wi::sub (const_val, 1), mode);
+	    }
 	  break;
 
 	default:

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Use wi:: in canon_condition
  2015-04-28 13:56 Use wi:: in canon_condition Richard Sandiford
@ 2015-04-28 17:05 ` Jeff Law
  2015-04-29 11:42   ` Richard Sandiford
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2015-04-28 17:05 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 04/28/2015 07:49 AM, Richard Sandiford wrote:
> Fix a simple case where we can generalise the CONST_INT handling to all
> integer constants (CONST_DOUBLE or CONST_WIDE_INT).
>
> Tested on x86_64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
>
> gcc/
> 	* loop-iv.c (canon_condition): Generalize to all types of integer
> 	constant.
OK.

If you have some test/code where this generalization helps, then it'd be 
greatly appreciated if you could add it as a test to the test suite.

jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Use wi:: in canon_condition
  2015-04-28 17:05 ` Jeff Law
@ 2015-04-29 11:42   ` Richard Sandiford
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Sandiford @ 2015-04-29 11:42 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

Jeff Law <law@redhat.com> writes:
> On 04/28/2015 07:49 AM, Richard Sandiford wrote:
>> Fix a simple case where we can generalise the CONST_INT handling to all
>> integer constants (CONST_DOUBLE or CONST_WIDE_INT).
>>
>> Tested on x86_64-linux-gnu.  OK to install?
>>
>> Thanks,
>> Richard
>>
>>
>> gcc/
>> 	* loop-iv.c (canon_condition): Generalize to all types of integer
>> 	constant.
> OK.

Thanks, applied.

> If you have some test/code where this generalization helps, then it'd be 
> greatly appreciated if you could add it as a test to the test suite.

This was just by inspection, so unfortunately I don't have any testcases.
Just trying to gradually reduce the specialness of host integers.

Richard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-29 11:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 13:56 Use wi:: in canon_condition Richard Sandiford
2015-04-28 17:05 ` Jeff Law
2015-04-29 11:42   ` Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).