public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109176] [13 Regression] internal compiler error: in to_constant, at poly-int.h:504
Date: Tue, 21 Mar 2023 09:53:18 +0000	[thread overview]
Message-ID: <bug-109176-4-c0RmyrewXr@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109176-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109176

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #5)
> Before veclower2 we had/have
>   _7 = ba_5(D) < a_6(D);
>   _8 = svnand_b_z (_7, _7, _7);
>   _9 = VEC_COND_EXPR <_7, _8, _7>;
> where _7/_8/_9 are all __SVBool_t.
> Before the r11-1445 changes, the VEC_COND_EXPR would be left untouched,
> because
> expand_vec_cond_expr_p (__SVBool_t, __SVBool_t, SSA_NAME) is true on aarch64.
> Now it doesn't, because _7 def_stmt is a comparison, and so
> expand_vec_cond_expr_p (__SVBool_t, VNx16QI, LT_EXPR).
> --- gcc/tree-vect-generic.cc.jj	2023-03-12 22:36:06.356178068 +0100
> +++ gcc/tree-vect-generic.cc	2023-03-20 16:31:03.321831866 +0100
> @@ -1063,6 +1063,12 @@ expand_vector_condition (gimple_stmt_ite
>        return true;
>      }
>  
> +  if (!TYPE_VECTOR_SUBPARTS (type).is_constant ()
> +      && VECTOR_BOOLEAN_TYPE_P (type)
> +      && VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (a))
> +      && expand_vec_cond_expr_p (type, TREE_TYPE (a), TREE_CODE (a)))
> +    return true;
> +
>    /* Handle vector boolean types with bitmasks.  If there is a comparison
>       and we can expand the comparison into the vector boolean bitmask,
>       or otherwise if it is compatible with type, we can transform
> basically restores the behaviour here for the SVE boolean types and makes it
> compile.
> Because otherwise, unless this would be solvable by the AVX512 "Handle
> vector boolean types with bitmasks." code the non-constant vector elts cases
> will always ICE in the following code,   int nunits =
> nunits_for_known_piecewise_op (type);
> requires constant TYPE_VECTOR_SUBPARTS and the code really isn't prepared to
> handle anything non-constant.

OK, so expand_vec_cond_expr_p does

bool
expand_vec_cond_expr_p (tree value_type, tree cmp_op_type, enum tree_code code)
{
  machine_mode value_mode = TYPE_MODE (value_type);
  machine_mode cmp_op_mode = TYPE_MODE (cmp_op_type);
  if (VECTOR_BOOLEAN_TYPE_P (cmp_op_type)
      && get_vcond_mask_icode (TYPE_MODE (value_type),
                               TYPE_MODE (cmp_op_type)) != CODE_FOR_nothing)
    return true;

first.  I think vector lowering should always check the original 'a'
if it is a mask, like with the following, there's no good reason to
special-case this just for VL vectors

diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
index 519a824ec72..c957c9aa7a9 100644
--- a/gcc/tree-vect-generic.cc
+++ b/gcc/tree-vect-generic.cc
@@ -1040,6 +1040,10 @@ expand_vector_condition (gimple_stmt_iterator *gsi,
bitmap dce_ssa_names)
   tree_code code = TREE_CODE (a);
   gassign *assign = NULL;

+  if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (a))
+      && expand_vec_cond_expr_p (type, TREE_TYPE (a), ERROR_MARK))
+    return true;
+
   if (code == SSA_NAME)
     {
       assign = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (a));
@@ -1053,14 +1057,14 @@ expand_vector_condition (gimple_stmt_iterator *gsi,
bitmap dce_ssa_names)
          comp_inner_type = TREE_TYPE (TREE_TYPE (a1));
          comp_width = vector_element_bits_tree (TREE_TYPE (a1));
        }
-    }

-  if (expand_vec_cond_expr_p (type, TREE_TYPE (a1), code)
-      || (integer_all_onesp (b) && integer_zerop (c)
-         && expand_vec_cmp_expr_p (type, TREE_TYPE (a1), code)))
-    {
-      gcc_assert (TREE_CODE (a) == SSA_NAME || TREE_CODE (a) == VECTOR_CST);
-      return true;
+      if (expand_vec_cond_expr_p (type, TREE_TYPE (a1), code)
+         || (integer_all_onesp (b) && integer_zerop (c)
+             && expand_vec_cmp_expr_p (type, TREE_TYPE (a1), code)))
+       {
+         gcc_assert (TREE_CODE (a) == SSA_NAME || TREE_CODE (a) ==
VECTOR_CST);
+         return true;
+       }
     }

   /* Handle vector boolean types with bitmasks.  If there is a comparison

  parent reply	other threads:[~2023-03-21  9:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 16:19 [Bug c++/109176] New: " malat at debian dot org
2023-03-17 16:43 ` [Bug c++/109176] " malat at debian dot org
2023-03-17 17:54 ` [Bug tree-optimization/109176] " ktkachov at gcc dot gnu.org
2023-03-20  9:17 ` [Bug tree-optimization/109176] [13 Regression] " rguenth at gcc dot gnu.org
2023-03-20  9:37 ` ktkachov at gcc dot gnu.org
2023-03-20 13:59 ` jakub at gcc dot gnu.org
2023-03-20 15:35 ` jakub at gcc dot gnu.org
2023-03-21  9:25 ` jakub at gcc dot gnu.org
2023-03-21  9:53 ` rguenth at gcc dot gnu.org [this message]
2023-03-21 10:28 ` jakub at gcc dot gnu.org
2023-03-21 10:41 ` jakub at gcc dot gnu.org
2023-03-21 10:57 ` ktkachov at gcc dot gnu.org
2023-03-21 12:03 ` jakub at gcc dot gnu.org
2023-03-21 12:12 ` rguenth at gcc dot gnu.org
2023-03-22  8:47 ` jakub at gcc dot gnu.org
2023-03-22 12:03 ` jakub at gcc dot gnu.org
2023-03-22 12:08 ` jakub at gcc dot gnu.org
2023-03-23  9:04 ` cvs-commit at gcc dot gnu.org
2023-03-23  9:08 ` [Bug tree-optimization/109176] [11/12 " jakub at gcc dot gnu.org
2023-04-18  7:15 ` cvs-commit at gcc dot gnu.org
2023-04-18  7:21 ` [Bug tree-optimization/109176] [11 " jakub at gcc dot gnu.org
2023-04-26  6:58 ` rguenth at gcc dot gnu.org
2023-05-02 20:16 ` cvs-commit at gcc dot gnu.org
2023-05-03 10:45 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109176-4-c0RmyrewXr@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).