[PATCH] Amend match.pd syntax with force-simplified results
Richard Biener
rguenther@suse.de
Mon Aug 3 08:34:38 GMT 2020
On Fri, 31 Jul 2020, Marc Glisse wrote:
> On Fri, 31 Jul 2020, Richard Biener wrote:
>
> > Or we simply automatically disable those patterns for GENERIC
> > (though that would probably be unexpected).
>
> Since the definition is not clear, whatever we do will be unexpected at least
> in some cases. Disabling it for GENERIC for now seems ok to me, we can always
> extend it later...
Fair enough. I'm going to test and install the following which means
! using patterns need to be guarded with #if GIMPLE for now.
Richard.
>From 3237456abe8d384ada9ef6b972ee0bd81caf8112 Mon Sep 17 00:00:00 2001
From: Richard Biener <rguenther@suse.de>
Date: Mon, 3 Aug 2020 10:30:49 +0200
Subject: [PATCH] mark match.pd ! not implemented on GENERIC
This makes us error when the ! operator modifier is encountered
when not targeting GIMPLE.
2020-08-03 Richard Biener <rguenther@suse.de>
* genmatch.c (parser::gimple): New.
(parser::parser): Initialize gimple flag member.
(parser::parse_expr): Error on ! operator modifier when
not targeting GIMPLE.
(main): Pass down gimple flag to parser ctor.
* doc/match-and-simplify.texi: Amend accordingly.
---
gcc/doc/match-and-simplify.texi | 3 ++-
gcc/genmatch.c | 11 ++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/gcc/doc/match-and-simplify.texi b/gcc/doc/match-and-simplify.texi
index 41980acbfe9..8752bd2afe1 100644
--- a/gcc/doc/match-and-simplify.texi
+++ b/gcc/doc/match-and-simplify.texi
@@ -374,7 +374,8 @@ 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.
+operations both simplify. Note this is currently only supported
+for code generation targeting @code{GIMPLE}.
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 88459d9686e..109dce2d469 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -3946,7 +3946,7 @@ write_header (FILE *f, const char *head)
class parser
{
public:
- parser (cpp_reader *);
+ parser (cpp_reader *, bool gimple);
private:
const cpp_token *next ();
@@ -3983,6 +3983,7 @@ private:
void finish_match_operand (operand *);
cpp_reader *r;
+ bool gimple;
vec<c_expr *> active_ifs;
vec<vec<user_id *> > active_fors;
hash_set<user_id *> *oper_lists_set;
@@ -4249,6 +4250,9 @@ 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;
}
@@ -5042,9 +5046,10 @@ parser::finish_match_operand (operand *op)
/* Main entry of the parser. Repeatedly parse outer control structures. */
-parser::parser (cpp_reader *r_)
+parser::parser (cpp_reader *r_, bool gimple_)
{
r = r_;
+ gimple = gimple_;
active_ifs = vNULL;
active_fors = vNULL;
simplifiers = vNULL;
@@ -5151,7 +5156,7 @@ main (int argc, char **argv)
#include "internal-fn.def"
/* Parse ahead! */
- parser p (r);
+ parser p (r, gimple);
if (gimple)
write_header (stdout, "gimple-match-head.c");
--
2.26.2
More information about the Gcc-patches
mailing list