diff mbox

[i386] Simplify vector_all_ones_operand

Message ID 87h9nu9t1b.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford Aug. 20, 2015, 10:02 a.m. UTC
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.

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

Bootstrapped & regression-tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard

gcc/
	* config/i386/predicates.md (vector_all_ones_operand): Use
	CONSTM1_RTX to simplify definition.

Comments

Uros Bizjak Aug. 20, 2015, 11:24 a.m. UTC | #1
On Thu, Aug 20, 2015 at 12:02 PM, Richard Sandiford
<richard.sandiford@arm.com> wrote:
> 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.
>
> This seemed like a better fix than using the helper functions
> that I'm about to post.
>
> Bootstrapped & regression-tested on x86_64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
> gcc/
>         * config/i386/predicates.md (vector_all_ones_operand): Use
>         CONSTM1_RTX to simplify definition.

OK.

Thanks,
Uros.

> diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
> index a9c8623..bc76a5b 100644
> --- a/gcc/config/i386/predicates.md
> +++ b/gcc/config/i386/predicates.md
> @@ -912,25 +912,9 @@
>
>  /* Return true if operand is a vector constant that is all ones. */
>  (define_predicate "vector_all_ones_operand"
> -  (match_code "const_vector")
> -{
> -  int nunits = GET_MODE_NUNITS (mode);
> -
> -  if (GET_CODE (op) == CONST_VECTOR
> -      && CONST_VECTOR_NUNITS (op) == nunits)
> -    {
> -      int i;
> -      for (i = 0; i < nunits; ++i)
> -        {
> -          rtx x = CONST_VECTOR_ELT (op, i);
> -          if (x != constm1_rtx)
> -            return false;
> -        }
> -      return true;
> -    }
> -
> -  return false;
> -})
> +  (and (match_code "const_vector")
> +       (match_test "INTEGRAL_MODE_P (GET_MODE (op))")
> +       (match_test "op == CONSTM1_RTX (GET_MODE (op))")))
>
>  ; Return true when OP is operand acceptable for standard SSE move.
>  (define_predicate "vector_move_operand"
>
diff mbox

Patch

diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index a9c8623..bc76a5b 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -912,25 +912,9 @@ 
 
 /* Return true if operand is a vector constant that is all ones. */
 (define_predicate "vector_all_ones_operand"
-  (match_code "const_vector")
-{
-  int nunits = GET_MODE_NUNITS (mode);
-
-  if (GET_CODE (op) == CONST_VECTOR
-      && CONST_VECTOR_NUNITS (op) == nunits)
-    {
-      int i;
-      for (i = 0; i < nunits; ++i)
-        {
-          rtx x = CONST_VECTOR_ELT (op, i);
-          if (x != constm1_rtx)
-            return false;
-        }
-      return true;
-    }
-
-  return false;
-})
+  (and (match_code "const_vector")
+       (match_test "INTEGRAL_MODE_P (GET_MODE (op))")
+       (match_test "op == CONSTM1_RTX (GET_MODE (op))")))
 
 ; Return true when OP is operand acceptable for standard SSE move.
 (define_predicate "vector_move_operand"