public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/clyon/heads/mve-autovec)] fix VECTOR_BOOL_MODE
@ 2022-01-12 8:28 Christophe Lyon
0 siblings, 0 replies; only message in thread
From: Christophe Lyon @ 2022-01-12 8:28 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e8e6ff883d7e225e7d0ce341b5f770be61677daf
commit e8e6ff883d7e225e7d0ce341b5f770be61677daf
Author: Christophe Lyon <christophe.lyon@foss.st.com>
Date: Wed Dec 8 08:00:50 2021 +0000
fix VECTOR_BOOL_MODE
Diff:
---
gcc/config/aarch64/aarch64-modes.def | 8 ++++----
gcc/config/arm/arm-modes.def | 9 ++++++---
gcc/emit-rtl.c | 9 ++++++---
gcc/genmodes.c | 13 +++++++------
gcc/rtx-vector-builder.c | 4 +++-
gcc/simplify-rtx.c | 8 ++++----
gcc/varasm.c | 7 +++++--
7 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/gcc/config/aarch64/aarch64-modes.def b/gcc/config/aarch64/aarch64-modes.def
index ac97d222789..1bb9fcfefa5 100644
--- a/gcc/config/aarch64/aarch64-modes.def
+++ b/gcc/config/aarch64/aarch64-modes.def
@@ -47,10 +47,10 @@ ADJUST_FLOAT_FORMAT (HF, &ieee_half_format);
/* Vector modes. */
-VECTOR_BOOL_MODE (VNx16BI, 16, 2);
-VECTOR_BOOL_MODE (VNx8BI, 8, 2);
-VECTOR_BOOL_MODE (VNx4BI, 4, 2);
-VECTOR_BOOL_MODE (VNx2BI, 2, 2);
+VECTOR_BOOL_MODE (VNx16BI, 16, BI, 2);
+VECTOR_BOOL_MODE (VNx8BI, 8, BI, 2);
+VECTOR_BOOL_MODE (VNx4BI, 4, BI, 2);
+VECTOR_BOOL_MODE (VNx2BI, 2, BI, 2);
ADJUST_NUNITS (VNx16BI, aarch64_sve_vg * 8);
ADJUST_NUNITS (VNx8BI, aarch64_sve_vg * 4);
diff --git a/gcc/config/arm/arm-modes.def b/gcc/config/arm/arm-modes.def
index b414a709a62..068bbebe63d 100644
--- a/gcc/config/arm/arm-modes.def
+++ b/gcc/config/arm/arm-modes.def
@@ -85,9 +85,12 @@ VECTOR_MODE (FLOAT, BF, 4); /* V4BF. */
VECTOR_MODE (FLOAT, BF, 8); /* V8BF. */
/* Predicates for MVE. */
-VECTOR_BOOL_MODE (V16BI, 16, 2);
-VECTOR_BOOL_MODE (V8BI, 8, 2);
-VECTOR_BOOL_MODE (V4BI, 4, 2);
+FRACTIONAL_INT_MODE (B2I, 2, 1);
+FRACTIONAL_INT_MODE (B4I, 4, 1);
+
+VECTOR_BOOL_MODE (V16BI, 16, BI, 2);
+VECTOR_BOOL_MODE (V8BI, 8, B2I, 2);
+VECTOR_BOOL_MODE (V4BI, 4, B4I, 2);
/* Fraction and accumulator vector modes. */
VECTOR_MODES (FRACT, 4); /* V4QQ V2HQ */
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index e6158f243c0..6a50d9a704f 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -6254,13 +6254,16 @@ init_emit_once (void)
const_tiny_rtx[0][(int) mode] = gen_rtx_CONCAT (mode, inner, inner);
}
- /* As for BImode, "all 1" and "all -1" are unsigned and signed
- interpretations of the same value. */
FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_BOOL)
{
const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
const_tiny_rtx[3][(int) mode] = gen_const_vector (mode, 3);
- const_tiny_rtx[1][(int) mode] = const_tiny_rtx[3][(int) mode];
+ if (GET_MODE_INNER (mode) == BImode)
+ /* As for BImode, "all 1" and "all -1" are unsigned and signed
+ interpretations of the same value. */
+ const_tiny_rtx[1][(int) mode] = const_tiny_rtx[3][(int) mode];
+ else
+ const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1);
}
FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_INT)
diff --git a/gcc/genmodes.c b/gcc/genmodes.c
index ecc8b448406..4a8361572d5 100644
--- a/gcc/genmodes.c
+++ b/gcc/genmodes.c
@@ -548,17 +548,18 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
/* Create a vector of booleans called NAME with COUNT elements and
BYTESIZE bytes in total. */
-#define VECTOR_BOOL_MODE(NAME, COUNT, BYTESIZE) \
- make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, __LINE__)
+#define VECTOR_BOOL_MODE(NAME, COUNT, COMPONENT, BYTESIZE) \
+ make_vector_bool_mode (#NAME, COUNT, #COMPONENT, BYTESIZE, \
+ __FILE__, __LINE__)
static void ATTRIBUTE_UNUSED
make_vector_bool_mode (const char *name, unsigned int count,
- unsigned int bytesize, const char *file,
- unsigned int line)
+ const char *component, unsigned int bytesize,
+ const char *file, unsigned int line)
{
- struct mode_data *m = find_mode ("BI");
+ struct mode_data *m = find_mode (component);
if (!m)
{
- error ("%s:%d: no mode \"BI\"", file, line);
+ error ("%s:%d: no mode \"%s\"", file, line, component);
return;
}
diff --git a/gcc/rtx-vector-builder.c b/gcc/rtx-vector-builder.c
index cf9b3dd1af9..182278d4425 100644
--- a/gcc/rtx-vector-builder.c
+++ b/gcc/rtx-vector-builder.c
@@ -90,8 +90,10 @@ rtx_vector_builder::find_cached_value ()
if (GET_MODE_CLASS (m_mode) == MODE_VECTOR_BOOL)
{
- if (elt == const1_rtx || elt == constm1_rtx)
+ if (elt == const1_rtx)
return CONST1_RTX (m_mode);
+ else if (elt == constm1_rtx)
+ return CONSTM1_RTX (m_mode);
else if (elt == const0_rtx)
return CONST0_RTX (m_mode);
else
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 153a9964d2c..24185b84188 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -6866,12 +6866,13 @@ native_encode_rtx (machine_mode mode, rtx x, vec<target_unit> &bytes,
/* This is the only case in which elements can be smaller than
a byte. */
gcc_assert (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL);
+ auto mask = GET_MODE_MASK (GET_MODE_INNER (mode));
for (unsigned int i = 0; i < num_bytes; ++i)
{
target_unit value = 0;
for (unsigned int j = 0; j < BITS_PER_UNIT; j += elt_bits)
{
- value |= (INTVAL (CONST_VECTOR_ELT (x, elt)) & 1) << j;
+ value |= (INTVAL (CONST_VECTOR_ELT (x, elt)) & mask) << j;
elt += 1;
}
bytes.quick_push (value);
@@ -7015,9 +7016,8 @@ native_decode_vector_rtx (machine_mode mode, const vec<target_unit> &bytes,
unsigned int bit_index = first_byte * BITS_PER_UNIT + i * elt_bits;
unsigned int byte_index = bit_index / BITS_PER_UNIT;
unsigned int lsb = bit_index % BITS_PER_UNIT;
- builder.quick_push (bytes[byte_index] & (1 << lsb)
- ? CONST1_RTX (BImode)
- : CONST0_RTX (BImode));
+ unsigned int value = bytes[byte_index] >> lsb;
+ builder.quick_push (gen_int_mode (value, GET_MODE_INNER (mode)));
}
}
else
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 09316c62050..6ad624e2805 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -4087,6 +4087,7 @@ output_constant_pool_2 (fixed_size_mode mode, rtx x, unsigned int align)
unsigned int elt_bits = GET_MODE_BITSIZE (mode) / nelts;
unsigned int int_bits = MAX (elt_bits, BITS_PER_UNIT);
scalar_int_mode int_mode = int_mode_for_size (int_bits, 0).require ();
+ unsigned int mask = GET_MODE_MASK (GET_MODE_INNER (mode));
/* Build the constant up one integer at a time. */
unsigned int elts_per_int = int_bits / elt_bits;
@@ -4095,8 +4096,10 @@ output_constant_pool_2 (fixed_size_mode mode, rtx x, unsigned int align)
unsigned HOST_WIDE_INT value = 0;
unsigned int limit = MIN (nelts - i, elts_per_int);
for (unsigned int j = 0; j < limit; ++j)
- if (INTVAL (CONST_VECTOR_ELT (x, i + j)) != 0)
- value |= 1 << (j * elt_bits);
+ {
+ auto elt = INTVAL (CONST_VECTOR_ELT (x, i + j));
+ value |= (elt & mask) << (j * elt_bits);
+ }
output_constant_pool_2 (int_mode, gen_int_mode (value, int_mode),
i != 0 ? MIN (align, int_bits) : align);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-12 8:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 8:28 [gcc(refs/users/clyon/heads/mve-autovec)] fix VECTOR_BOOL_MODE Christophe Lyon
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).