* [PATCH] Fix ICE in vectorizable_nonlinear_induction with bitfield.
@ 2023-11-14 0:55 liuhongt
2023-11-14 8:32 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: liuhongt @ 2023-11-14 0:55 UTC (permalink / raw)
To: gcc-patches; +Cc: crazylht, hjl.tools
if (TREE_CODE (init_expr) == INTEGER_CST)
init_expr = fold_convert (TREE_TYPE (vectype), init_expr);
else
gcc_assert (tree_nop_conversion_p (TREE_TYPE (vectype),
TREE_TYPE (init_expr)));
and init_expr is a 24 bit integer type while vectype has 32bit components.
The "fix" is to bail out instead of asserting.
Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
Ok for trunk?(and backport to GCC-13)
gcc/ChangeLog:
PR tree-optimization/112496
* tree-vect-loop.cc (vectorizable_nonlinear_induction): Return
false when !tree_nop_conversion_p (TREE_TYPE (vectype),
TREE_TYPE (init_expr).
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr112496.c: New test.
---
gcc/testsuite/gcc.target/i386/pr112496.c | 7 +++++++
gcc/tree-vect-loop.cc | 13 ++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr112496.c
diff --git a/gcc/testsuite/gcc.target/i386/pr112496.c b/gcc/testsuite/gcc.target/i386/pr112496.c
new file mode 100644
index 00000000000..c478fda9cce
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr112496.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct T { int x : 24; } v;
+void f1(int x) {
+ while (v.x - ((v.x <<= 1) - v.x)) ;
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 1304b7ece79..75d69bbc30e 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -9429,9 +9429,16 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo,
if (TREE_CODE (init_expr) == INTEGER_CST)
init_expr = fold_convert (TREE_TYPE (vectype), init_expr);
- else
- gcc_assert (tree_nop_conversion_p (TREE_TYPE (vectype),
- TREE_TYPE (init_expr)));
+ else if (!tree_nop_conversion_p (TREE_TYPE (vectype), TREE_TYPE (init_expr)))
+ {
+ /* INIT_EXPR could be a bit_field, bail out for such case. */
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "nonlinear induction vectorization failed:"
+ " component type of vectype is not a nop conversion"
+ " from type of init_expr.\n");
+ return false;
+ }
switch (induction_type)
{
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix ICE in vectorizable_nonlinear_induction with bitfield.
2023-11-14 0:55 [PATCH] Fix ICE in vectorizable_nonlinear_induction with bitfield liuhongt
@ 2023-11-14 8:32 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-11-14 8:32 UTC (permalink / raw)
To: liuhongt; +Cc: gcc-patches, crazylht, hjl.tools
On Tue, Nov 14, 2023 at 1:56 AM liuhongt <hongtao.liu@intel.com> wrote:
>
> if (TREE_CODE (init_expr) == INTEGER_CST)
> init_expr = fold_convert (TREE_TYPE (vectype), init_expr);
> else
> gcc_assert (tree_nop_conversion_p (TREE_TYPE (vectype),
> TREE_TYPE (init_expr)));
>
> and init_expr is a 24 bit integer type while vectype has 32bit components.
>
> The "fix" is to bail out instead of asserting.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
> Ok for trunk?(and backport to GCC-13)
OK for both.
Thanks,
Richard.
> gcc/ChangeLog:
>
> PR tree-optimization/112496
> * tree-vect-loop.cc (vectorizable_nonlinear_induction): Return
> false when !tree_nop_conversion_p (TREE_TYPE (vectype),
> TREE_TYPE (init_expr).
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/i386/pr112496.c: New test.
> ---
> gcc/testsuite/gcc.target/i386/pr112496.c | 7 +++++++
> gcc/tree-vect-loop.cc | 13 ++++++++++---
> 2 files changed, 17 insertions(+), 3 deletions(-)
> create mode 100644 gcc/testsuite/gcc.target/i386/pr112496.c
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr112496.c b/gcc/testsuite/gcc.target/i386/pr112496.c
> new file mode 100644
> index 00000000000..c478fda9cce
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr112496.c
> @@ -0,0 +1,7 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +struct T { int x : 24; } v;
> +void f1(int x) {
> + while (v.x - ((v.x <<= 1) - v.x)) ;
> +}
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index 1304b7ece79..75d69bbc30e 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -9429,9 +9429,16 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo,
>
> if (TREE_CODE (init_expr) == INTEGER_CST)
> init_expr = fold_convert (TREE_TYPE (vectype), init_expr);
> - else
> - gcc_assert (tree_nop_conversion_p (TREE_TYPE (vectype),
> - TREE_TYPE (init_expr)));
> + else if (!tree_nop_conversion_p (TREE_TYPE (vectype), TREE_TYPE (init_expr)))
> + {
> + /* INIT_EXPR could be a bit_field, bail out for such case. */
> + if (dump_enabled_p ())
> + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> + "nonlinear induction vectorization failed:"
> + " component type of vectype is not a nop conversion"
> + " from type of init_expr.\n");
> + return false;
> + }
>
> switch (induction_type)
> {
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-14 8:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-14 0:55 [PATCH] Fix ICE in vectorizable_nonlinear_induction with bitfield liuhongt
2023-11-14 8:32 ` 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).