]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/109505 - backport match.pd ! support for GENERIC
authorRichard Biener <rguenther@suse.de>
Wed, 23 Feb 2022 12:47:01 +0000 (13:47 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 2 Jun 2023 07:45:38 +0000 (09:45 +0200)
The patch adds support for the ! modifier to GENERIC, backported
from r12-7361-gfdc46830f1b793.

2023-06-02  Richard Biener  <rguenther@suse.de>

PR tree-optimization/109505
* doc/match-and-simplify.texi: Amend ! documentation.
* genmatch.c (expr::gen_transform): Code-generate ! support
for GENERIC.
(parser::parse_expr): Allow ! for GENERIC.

gcc/doc/match-and-simplify.texi
gcc/genmatch.c

index e7e5a4f729951cf4c455376a8a5de93f71f1d030..b76aeac4121ef85ebabd1c7addf93cbea8c237ee 100644 (file)
@@ -374,8 +374,10 @@ for example
 
 which moves the outer @code{plus} operation to the inner arms
 of the @code{vec_cond} expression but only if the actual plus
-operations both simplify.  Note this is currently only supported
-for code generation targeting @code{GIMPLE}.
+operations both simplify.  Note that on @code{GENERIC} a simple
+operand means that the result satisfies @code{!EXPR_P} which
+can be limiting if the operation itself simplifies but the
+remaining operand is an (unrelated) expression.
 
 As intermediate conversions are often optional there is a way to
 avoid the need to repeat patterns both with and without such
index 3b99705606cc9ae6ada12f1ff20479adf946eae8..e22158665fb3fb81990b991a5cde5b2033b712a1 100644 (file)
@@ -2554,19 +2554,20 @@ expr::gen_transform (FILE *f, int indent, const char *dest, bool gimple,
        fprintf_indent (f, indent, "_r%d = fold_build%d_loc (loc, %s, %s",
                        depth, ops.length(), opr_name, type);
       else
-       {
-         fprintf_indent (f, indent, "{\n");
-         fprintf_indent (f, indent, "  _r%d = maybe_build_call_expr_loc (loc, "
-                         "%s, %s, %d", depth, opr_name, type, ops.length());
-       }
+       fprintf_indent (f, indent, "_r%d = maybe_build_call_expr_loc (loc, "
+                       "%s, %s, %d", depth, opr_name, type, ops.length());
       for (unsigned i = 0; i < ops.length (); ++i)
        fprintf (f, ", _o%d[%u]", depth, i);
       fprintf (f, ");\n");
       if (opr->kind != id_base::CODE)
        {
-         fprintf_indent (f, indent, "  if (!_r%d)\n", depth);
-         fprintf_indent (f, indent, "    goto %s;\n", fail_label);
-         fprintf_indent (f, indent, "}\n");
+         fprintf_indent (f, indent, "if (!_r%d)\n", depth);
+         fprintf_indent (f, indent, "  goto %s;\n", fail_label);
+       }
+      if (force_leaf)
+       {
+         fprintf_indent (f, indent, "if (EXPR_P (_r%d))\n", depth);
+         fprintf_indent (f, indent, "  goto %s;\n", fail_label);
        }
       if (*opr == CONVERT_EXPR)
        {
@@ -4300,9 +4301,6 @@ parser::parse_expr ()
       && token->type == CPP_NOT
       && !(token->flags & PREV_WHITE))
     {
-      if (!gimple)
-       fatal_at (token, "forcing simplification to a leaf is not supported "
-                 "for GENERIC");
       eat_token (CPP_NOT);
       e->force_leaf = true;
     }