From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 83DC63858C53; Fri, 2 Jun 2023 07:46:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83DC63858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685691967; bh=D7rUJQ/7790p1ycUdYhLQIQopSYWwY8MeZO9OWuUE5Q=; h=From:To:Subject:Date:From; b=SKyRaFHl3SuUZWR+FQ3pEhHuhaGvcXRYCtwE16QlJKwC6V+buKP7Hr6+FgphzIkju a9Pv95tnzp+uQKFmNoFKScTNRRUPewek9nvscILdh/W0t06W8TJJ0FjSHODMv2Ikfl 32YTbXbn//VhnwkJUnOLi/xqDM6mx/tFFph23Qy8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-10840] middle-end/109505 - backport match.pd ! support for GENERIC X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: f8853ff5d20234c184b2b4a9952b0e4964ecc24a X-Git-Newrev: bfa476528ceeac96865a48c49f3f1a15d566d209 Message-Id: <20230602074607.83DC63858C53@sourceware.org> Date: Fri, 2 Jun 2023 07:46:07 +0000 (GMT) List-Id: https://gcc.gnu.org/g:bfa476528ceeac96865a48c49f3f1a15d566d209 commit r11-10840-gbfa476528ceeac96865a48c49f3f1a15d566d209 Author: Richard Biener Date: Wed Feb 23 13:47:01 2022 +0100 middle-end/109505 - backport match.pd ! support for GENERIC The patch adds support for the ! modifier to GENERIC, backported from r12-7361-gfdc46830f1b793. 2023-06-02 Richard Biener 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. Diff: --- gcc/doc/match-and-simplify.texi | 6 ++++-- gcc/genmatch.c | 20 +++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gcc/doc/match-and-simplify.texi b/gcc/doc/match-and-simplify.texi index e7e5a4f7299..b76aeac4121 100644 --- a/gcc/doc/match-and-simplify.texi +++ b/gcc/doc/match-and-simplify.texi @@ -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 diff --git a/gcc/genmatch.c b/gcc/genmatch.c index 3b99705606c..e22158665fb 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -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; }