aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-11-14 14:39:57 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-11-14 14:39:57 +0000
commitd083ee47a9828236016841356fc7207e7c90bbbd (patch)
tree90747a64f3a7312d7fcdd25bc7c864ff408c02df
parentf09552335030433018fd5f7f6b9848339b5ca2da (diff)
downloadgcc-d083ee47a9828236016841356fc7207e7c90bbbd.zip
gcc-d083ee47a9828236016841356fc7207e7c90bbbd.tar.gz
gcc-d083ee47a9828236016841356fc7207e7c90bbbd.tar.bz2
Replace mode_for_int_vector with related_int_vector_mode
mode_for_int_vector, like mode_for_vector, can sometimes return an integer mode or an unsupported vector mode. But no callers are interested in that case, and only want supported vector modes. This patch therefore replaces mode_for_int_vector with related_int_vector_mode, which gives the target a chance to pick its preferred vector mode for the given element mode and size. 2019-11-14 Richard Sandiford <richard.sandiford@arm.com> gcc/ * machmode.h (mode_for_int_vector): Delete. (related_int_vector_mode): Declare. * stor-layout.c (mode_for_int_vector): Delete. (related_int_vector_mode): New function. * optabs.c (expand_vec_perm_1): Use related_int_vector_mode instead of mode_for_int_vector. (expand_vec_perm_const): Likewise. * config/aarch64/aarch64.c (aarch64_emit_approx_sqrt): Likewise. (aarch64_evpc_sve_tbl): Likewise. * config/s390/s390.c (s390_expand_vec_compare_cc): Likewise. (s390_expand_vcond): Likewise. From-SVN: r278230
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/config/aarch64/aarch64.c6
-rw-r--r--gcc/config/s390/s390.c4
-rw-r--r--gcc/machmode.h15
-rw-r--r--gcc/optabs.c5
-rw-r--r--gcc/stor-layout.c35
6 files changed, 42 insertions, 37 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 54f2449..3131af7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,19 @@
2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
+ * machmode.h (mode_for_int_vector): Delete.
+ (related_int_vector_mode): Declare.
+ * stor-layout.c (mode_for_int_vector): Delete.
+ (related_int_vector_mode): New function.
+ * optabs.c (expand_vec_perm_1): Use related_int_vector_mode
+ instead of mode_for_int_vector.
+ (expand_vec_perm_const): Likewise.
+ * config/aarch64/aarch64.c (aarch64_emit_approx_sqrt): Likewise.
+ (aarch64_evpc_sve_tbl): Likewise.
+ * config/s390/s390.c (s390_expand_vec_compare_cc): Likewise.
+ (s390_expand_vcond): Likewise.
+
+2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
+
* target.def (related_mode): New hook.
* doc/tm.texi.in (TARGET_VECTORIZE_RELATED_MODE): New hook.
* doc/tm.texi: Regenerate.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 9a5f27f..b6c8d77 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -1816,7 +1816,7 @@ aarch64_sve_element_int_mode (machine_mode mode)
}
/* Return the integer vector mode associated with SVE mode MODE.
- Unlike mode_for_int_vector, this can handle the case in which
+ Unlike related_int_vector_mode, this can handle the case in which
MODE is a predicate (and thus has a different total size). */
machine_mode
@@ -12537,7 +12537,7 @@ aarch64_emit_approx_sqrt (rtx dst, rtx src, bool recp)
gcc_assert (use_rsqrt_p (mode));
machine_mode mmsk = (VECTOR_MODE_P (mode)
- ? mode_for_int_vector (mode).require ()
+ ? related_int_vector_mode (mode).require ()
: int_mode_for_mode (mode).require ());
rtx xmsk = gen_reg_rtx (mmsk);
if (!recp)
@@ -19068,7 +19068,7 @@ aarch64_evpc_sve_tbl (struct expand_vec_perm_d *d)
if (d->testing_p)
return true;
- machine_mode sel_mode = mode_for_int_vector (d->vmode).require ();
+ machine_mode sel_mode = related_int_vector_mode (d->vmode).require ();
rtx sel = vec_perm_indices_to_rtx (sel_mode, d->perm);
if (d->one_vector_p)
emit_unspec2 (d->target, UNSPEC_TBL, d->op0, force_reg (sel_mode, sel));
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index c761158..8cb19ea 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -6653,7 +6653,7 @@ s390_expand_vec_compare_cc (rtx target, enum rtx_code code,
case LE: cc_producer_mode = CCVFHEmode; code = GE; swap_p = true; break;
default: gcc_unreachable ();
}
- scratch_mode = mode_for_int_vector (GET_MODE (cmp1)).require ();
+ scratch_mode = related_int_vector_mode (GET_MODE (cmp1)).require ();
if (inv_p)
all_p = !all_p;
@@ -6759,7 +6759,7 @@ s390_expand_vcond (rtx target, rtx then, rtx els,
/* We always use an integral type vector to hold the comparison
result. */
- result_mode = mode_for_int_vector (cmp_mode).require ();
+ result_mode = related_int_vector_mode (cmp_mode).require ();
result_target = gen_reg_rtx (result_mode);
/* We allow vector immediates as comparison operands that
diff --git a/gcc/machmode.h b/gcc/machmode.h
index 906b216..6750833 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -879,22 +879,9 @@ smallest_int_mode_for_size (poly_uint64 size)
extern opt_scalar_int_mode int_mode_for_mode (machine_mode);
extern opt_machine_mode bitwise_mode_for_mode (machine_mode);
extern opt_machine_mode mode_for_vector (scalar_mode, poly_uint64);
-extern opt_machine_mode mode_for_int_vector (unsigned int, poly_uint64);
extern opt_machine_mode related_vector_mode (machine_mode, scalar_mode,
poly_uint64 = 0);
-
-/* Return the integer vector equivalent of MODE, if one exists. In other
- words, return the mode for an integer vector that has the same number
- of bits as MODE and the same number of elements as MODE, with the
- latter being 1 if MODE is scalar. The returned mode can be either
- an integer mode or a vector mode. */
-
-inline opt_machine_mode
-mode_for_int_vector (machine_mode mode)
-{
- return mode_for_int_vector (GET_MODE_UNIT_BITSIZE (mode),
- GET_MODE_NUNITS (mode));
-}
+extern opt_machine_mode related_int_vector_mode (machine_mode);
/* A class for iterating through possible bitfield modes. */
class bit_field_mode_iterator
diff --git a/gcc/optabs.c b/gcc/optabs.c
index d6701df..3c3dd9e 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -5542,7 +5542,7 @@ expand_vec_perm_1 (enum insn_code icode, rtx target,
class expand_operand ops[4];
gcc_assert (GET_MODE_CLASS (smode) == MODE_VECTOR_INT
- || mode_for_int_vector (tmode).require () == smode);
+ || related_int_vector_mode (tmode).require () == smode);
create_output_operand (&ops[0], target, tmode);
create_input_operand (&ops[3], sel, smode);
@@ -5679,8 +5679,7 @@ expand_vec_perm_const (machine_mode mode, rtx v0, rtx v1,
/* The optabs are only defined for selectors with the same width
as the values being permuted. */
machine_mode required_sel_mode;
- if (!mode_for_int_vector (mode).exists (&required_sel_mode)
- || !VECTOR_MODE_P (required_sel_mode))
+ if (!related_int_vector_mode (mode).exists (&required_sel_mode))
{
delete_insns_since (last);
return NULL_RTX;
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index c1b724f..7d00364 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -515,21 +515,6 @@ mode_for_vector (scalar_mode innermode, poly_uint64 nunits)
return opt_machine_mode ();
}
-/* Return the mode for a vector that has NUNITS integer elements of
- INT_BITS bits each, if such a mode exists. The mode can be either
- an integer mode or a vector mode. */
-
-opt_machine_mode
-mode_for_int_vector (unsigned int int_bits, poly_uint64 nunits)
-{
- scalar_int_mode int_mode;
- machine_mode vec_mode;
- if (int_mode_for_size (int_bits, 0).exists (&int_mode)
- && mode_for_vector (int_mode, nunits).exists (&vec_mode))
- return vec_mode;
- return opt_machine_mode ();
-}
-
/* If a piece of code is using vector mode VECTOR_MODE and also wants
to operate on elements of mode ELEMENT_MODE, return the vector mode
it should use for those elements. If NUNITS is nonzero, ensure that
@@ -550,6 +535,26 @@ related_vector_mode (machine_mode vector_mode, scalar_mode element_mode,
return targetm.vectorize.related_mode (vector_mode, element_mode, nunits);
}
+/* If a piece of code is using vector mode VECTOR_MODE and also wants
+ to operate on integer vectors with the same element size and number
+ of elements, return the vector mode it should use. Return an empty
+ opt_machine_mode if there is no supported vector mode with the
+ required properties.
+
+ Unlike mode_for_vector. any returned mode is guaranteed to satisfy
+ both VECTOR_MODE_P and targetm.vector_mode_supported_p. */
+
+opt_machine_mode
+related_int_vector_mode (machine_mode vector_mode)
+{
+ gcc_assert (VECTOR_MODE_P (vector_mode));
+ scalar_int_mode int_mode;
+ if (int_mode_for_mode (GET_MODE_INNER (vector_mode)).exists (&int_mode))
+ return related_vector_mode (vector_mode, int_mode,
+ GET_MODE_NUNITS (vector_mode));
+ return opt_machine_mode ();
+}
+
/* Return the alignment of MODE. This will be bounded by 1 and
BIGGEST_ALIGNMENT. */