* [PATCH, PR69956] Fix multi-step conversion of boolean vectors
@ 2016-02-26 9:23 Ilya Enkovich
2016-03-01 10:52 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Ilya Enkovich @ 2016-02-26 9:23 UTC (permalink / raw)
To: gcc-patches
Hi,
Currently multi-step vector conversion tries to compute
intermediate type from its mode but it doesn't work for
boolean vectors. This patch introduces a computation
of intermediate vector masks. Bootstrapped and tested
on x86_64-pc-linux-gnu. OK for trunk?
Thanks,
Ilya
--
gcc/
2016-02-26 Ilya Enkovich <enkovich.gnu@gmail.com>
PR tree-optimization/69956
* tree-vect-stmts.c (supportable_widening_operation): Support
multi-step conversion of boolean vectors.
(supportable_narrowing_operation): Likewise.
gcc/testsuite/
2016-02-26 Ilya Enkovich <enkovich.gnu@gmail.com>
PR tree-optimization/69956
* gcc.dg/pr69956.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr69956.c b/gcc/testsuite/gcc.dg/pr69956.c
new file mode 100644
index 0000000..37d24d4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr69956.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize" } */
+/* { dg-additional-options "-march=skylake-avx512" { target { i?86-*-* x86_64-*-* } } } */
+
+void
+fn1 (char *b, char *d, int *c, int i)
+{
+ for (; i; i++, d++)
+ if (b[i])
+ *d = c[i];
+}
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 9678d7c..182b277 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -9000,9 +9000,19 @@ supportable_widening_operation (enum tree_code code, gimple *stmt,
for (i = 0; i < MAX_INTERM_CVT_STEPS; i++)
{
intermediate_mode = insn_data[icode1].operand[0].mode;
- intermediate_type
- = lang_hooks.types.type_for_mode (intermediate_mode,
- TYPE_UNSIGNED (prev_type));
+ if (VECTOR_BOOLEAN_TYPE_P (prev_type))
+ {
+ intermediate_type
+ = build_truth_vector_type (TYPE_VECTOR_SUBPARTS (prev_type) / 2,
+ current_vector_size);
+ if (intermediate_mode != TYPE_MODE (intermediate_type))
+ return false;
+ }
+ else
+ intermediate_type
+ = lang_hooks.types.type_for_mode (intermediate_mode,
+ TYPE_UNSIGNED (prev_type));
+
optab3 = optab_for_tree_code (c1, intermediate_type, optab_default);
optab4 = optab_for_tree_code (c2, intermediate_type, optab_default);
@@ -9065,7 +9075,7 @@ supportable_narrowing_operation (enum tree_code code,
tree vectype = vectype_in;
tree narrow_vectype = vectype_out;
enum tree_code c1;
- tree intermediate_type;
+ tree intermediate_type, prev_type;
machine_mode intermediate_mode, prev_mode;
int i;
bool uns;
@@ -9111,6 +9121,7 @@ supportable_narrowing_operation (enum tree_code code,
/* Check if it's a multi-step conversion that can be done using intermediate
types. */
prev_mode = vec_mode;
+ prev_type = vectype;
if (code == FIX_TRUNC_EXPR)
uns = TYPE_UNSIGNED (vectype_out);
else
@@ -9145,8 +9156,17 @@ supportable_narrowing_operation (enum tree_code code,
for (i = 0; i < MAX_INTERM_CVT_STEPS; i++)
{
intermediate_mode = insn_data[icode1].operand[0].mode;
- intermediate_type
- = lang_hooks.types.type_for_mode (intermediate_mode, uns);
+ if (VECTOR_BOOLEAN_TYPE_P (prev_type))
+ {
+ intermediate_type
+ = build_truth_vector_type (TYPE_VECTOR_SUBPARTS (prev_type) * 2,
+ current_vector_size);
+ if (intermediate_mode != TYPE_MODE (intermediate_type))
+ return false;
+ }
+ else
+ intermediate_type
+ = lang_hooks.types.type_for_mode (intermediate_mode, uns);
interm_optab
= optab_for_tree_code (VEC_PACK_TRUNC_EXPR, intermediate_type,
optab_default);
@@ -9164,6 +9184,7 @@ supportable_narrowing_operation (enum tree_code code,
return true;
prev_mode = intermediate_mode;
+ prev_type = intermediate_type;
optab1 = interm_optab;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, PR69956] Fix multi-step conversion of boolean vectors
2016-02-26 9:23 [PATCH, PR69956] Fix multi-step conversion of boolean vectors Ilya Enkovich
@ 2016-03-01 10:52 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-03-01 10:52 UTC (permalink / raw)
To: Ilya Enkovich; +Cc: GCC Patches
On Fri, Feb 26, 2016 at 10:22 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> Currently multi-step vector conversion tries to compute
> intermediate type from its mode but it doesn't work for
> boolean vectors. This patch introduces a computation
> of intermediate vector masks. Bootstrapped and tested
> on x86_64-pc-linux-gnu. OK for trunk?
Ok.
Richard.
> Thanks,
> Ilya
> --
> gcc/
>
> 2016-02-26 Ilya Enkovich <enkovich.gnu@gmail.com>
>
> PR tree-optimization/69956
> * tree-vect-stmts.c (supportable_widening_operation): Support
> multi-step conversion of boolean vectors.
> (supportable_narrowing_operation): Likewise.
>
> gcc/testsuite/
>
> 2016-02-26 Ilya Enkovich <enkovich.gnu@gmail.com>
>
> PR tree-optimization/69956
> * gcc.dg/pr69956.c: New test.
>
>
> diff --git a/gcc/testsuite/gcc.dg/pr69956.c b/gcc/testsuite/gcc.dg/pr69956.c
> new file mode 100644
> index 0000000..37d24d4
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr69956.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -ftree-vectorize" } */
> +/* { dg-additional-options "-march=skylake-avx512" { target { i?86-*-* x86_64-*-* } } } */
> +
> +void
> +fn1 (char *b, char *d, int *c, int i)
> +{
> + for (; i; i++, d++)
> + if (b[i])
> + *d = c[i];
> +}
> diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
> index 9678d7c..182b277 100644
> --- a/gcc/tree-vect-stmts.c
> +++ b/gcc/tree-vect-stmts.c
> @@ -9000,9 +9000,19 @@ supportable_widening_operation (enum tree_code code, gimple *stmt,
> for (i = 0; i < MAX_INTERM_CVT_STEPS; i++)
> {
> intermediate_mode = insn_data[icode1].operand[0].mode;
> - intermediate_type
> - = lang_hooks.types.type_for_mode (intermediate_mode,
> - TYPE_UNSIGNED (prev_type));
> + if (VECTOR_BOOLEAN_TYPE_P (prev_type))
> + {
> + intermediate_type
> + = build_truth_vector_type (TYPE_VECTOR_SUBPARTS (prev_type) / 2,
> + current_vector_size);
> + if (intermediate_mode != TYPE_MODE (intermediate_type))
> + return false;
> + }
> + else
> + intermediate_type
> + = lang_hooks.types.type_for_mode (intermediate_mode,
> + TYPE_UNSIGNED (prev_type));
> +
> optab3 = optab_for_tree_code (c1, intermediate_type, optab_default);
> optab4 = optab_for_tree_code (c2, intermediate_type, optab_default);
>
> @@ -9065,7 +9075,7 @@ supportable_narrowing_operation (enum tree_code code,
> tree vectype = vectype_in;
> tree narrow_vectype = vectype_out;
> enum tree_code c1;
> - tree intermediate_type;
> + tree intermediate_type, prev_type;
> machine_mode intermediate_mode, prev_mode;
> int i;
> bool uns;
> @@ -9111,6 +9121,7 @@ supportable_narrowing_operation (enum tree_code code,
> /* Check if it's a multi-step conversion that can be done using intermediate
> types. */
> prev_mode = vec_mode;
> + prev_type = vectype;
> if (code == FIX_TRUNC_EXPR)
> uns = TYPE_UNSIGNED (vectype_out);
> else
> @@ -9145,8 +9156,17 @@ supportable_narrowing_operation (enum tree_code code,
> for (i = 0; i < MAX_INTERM_CVT_STEPS; i++)
> {
> intermediate_mode = insn_data[icode1].operand[0].mode;
> - intermediate_type
> - = lang_hooks.types.type_for_mode (intermediate_mode, uns);
> + if (VECTOR_BOOLEAN_TYPE_P (prev_type))
> + {
> + intermediate_type
> + = build_truth_vector_type (TYPE_VECTOR_SUBPARTS (prev_type) * 2,
> + current_vector_size);
> + if (intermediate_mode != TYPE_MODE (intermediate_type))
> + return false;
> + }
> + else
> + intermediate_type
> + = lang_hooks.types.type_for_mode (intermediate_mode, uns);
> interm_optab
> = optab_for_tree_code (VEC_PACK_TRUNC_EXPR, intermediate_type,
> optab_default);
> @@ -9164,6 +9184,7 @@ supportable_narrowing_operation (enum tree_code code,
> return true;
>
> prev_mode = intermediate_mode;
> + prev_type = intermediate_type;
> optab1 = interm_optab;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-01 10:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-26 9:23 [PATCH, PR69956] Fix multi-step conversion of boolean vectors Ilya Enkovich
2016-03-01 10:52 ` Richard Biener
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).