public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [SPARC] Simplify const_all_ones_operand
@ 2015-08-20 10:34 Richard Sandiford
  2015-09-12  9:31 ` Eric Botcazou
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2015-08-20 10:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: ebotcazou

gen_rtx_CONST_VECTOR ensures that there is a single instance of:

   (const_vector:M [(const_int -1) ... (const_int -1)])

for each M, so pointer equality with CONSTM1_RTX is enough.  Also,
HOST_BITS_PER_WIDE_INT == 32 is doubly dead: HOST_WIDE_INT is always
64 bits now, and we always use const_int rather than const_double
or const_wide_int for all-ones values (or any other value that
fits in a signed HOST_WIDE_INT).

This seemed like a better fix than using the helper functions
that I'm about to post.

Tested with a cross-compiler and ensured that the predicate was
still accepting all (-)1 values.  OK to install?

Thanks,
Richard

gcc/
	* config/sparc/predicates.md (const_all_ones_operand): Use
	CONSTM1_RTX to simplify definition.

diff --git a/gcc/config/sparc/predicates.md b/gcc/config/sparc/predicates.md
index 88537c6..aa45f8e 100644
--- a/gcc/config/sparc/predicates.md
+++ b/gcc/config/sparc/predicates.md
@@ -27,31 +27,9 @@
 ;; Return true if the integer representation of OP is
 ;; all-ones.
 (define_predicate "const_all_ones_operand"
-  (match_code "const_int,const_double,const_vector")
-{
-  if (GET_CODE (op) == CONST_INT && INTVAL (op) == -1)
-    return true;
-#if HOST_BITS_PER_WIDE_INT == 32
-  if (GET_CODE (op) == CONST_DOUBLE
-      && GET_MODE (op) == VOIDmode
-      && CONST_DOUBLE_HIGH (op) == ~(HOST_WIDE_INT)0
-      && CONST_DOUBLE_LOW (op) == ~(HOST_WIDE_INT)0)
-    return true;
-#endif
-  if (GET_CODE (op) == CONST_VECTOR)
-    {
-      int i, num_elem = CONST_VECTOR_NUNITS (op);
-
-      for (i = 0; i < num_elem; i++)
-        {
-          rtx n = CONST_VECTOR_ELT (op, i);
-          if (! const_all_ones_operand (n, mode))
-            return false;
-        }
-      return true;
-    }
-  return false;
-})
+  (and (match_code "const_int,const_double,const_vector")
+       (match_test "INTEGRAL_MODE_P (GET_MODE (op))")
+       (match_test "op == CONSTM1_RTX (GET_MODE (op))")))
 
 ;; Return true if OP is the integer constant 4096.
 (define_predicate "const_4096_operand"

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

* Re: [SPARC] Simplify const_all_ones_operand
  2015-08-20 10:34 [SPARC] Simplify const_all_ones_operand Richard Sandiford
@ 2015-09-12  9:31 ` Eric Botcazou
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Botcazou @ 2015-09-12  9:31 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches

[Sorry for the delay]

> gen_rtx_CONST_VECTOR ensures that there is a single instance of:
> 
>    (const_vector:M [(const_int -1) ... (const_int -1)])
> 
> for each M, so pointer equality with CONSTM1_RTX is enough.  Also,
> HOST_BITS_PER_WIDE_INT == 32 is doubly dead: HOST_WIDE_INT is always
> 64 bits now, and we always use const_int rather than const_double
> or const_wide_int for all-ones values (or any other value that
> fits in a signed HOST_WIDE_INT).
> 
> This seemed like a better fix than using the helper functions
> that I'm about to post.
> 
> Tested with a cross-compiler and ensured that the predicate was
> still accepting all (-)1 values.  OK to install?
> 
> Thanks,
> Richard
> 
> gcc/
> 	* config/sparc/predicates.md (const_all_ones_operand): Use
> 	CONSTM1_RTX to simplify definition.

OK, thanks.

-- 
Eric Botcazou

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

end of thread, other threads:[~2015-09-12  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-20 10:34 [SPARC] Simplify const_all_ones_operand Richard Sandiford
2015-09-12  9:31 ` Eric Botcazou

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).