diff options
author | Richard Biener <rguenther@suse.de> | 2020-07-31 14:24:26 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-07-31 15:19:00 +0200 |
commit | 14c35be3bf493859b92c3c6ca7893075212169ab (patch) | |
tree | e15ade239c1f5da5effb318309783e243ab67bf6 /gcc/doc/match-and-simplify.texi | |
parent | c89366b12ff4f36253bae125b794cbe687f7e40b (diff) | |
download | gcc-14c35be3bf493859b92c3c6ca7893075212169ab.zip gcc-14c35be3bf493859b92c3c6ca7893075212169ab.tar.gz gcc-14c35be3bf493859b92c3c6ca7893075212169ab.tar.bz2 |
Amend match.pd syntax with force-simplified results
This adds a ! marker to result expressions that should simplify
(and if not fail the simplification). This can for example be
used like
(simplify
(plus (vec_cond:s @0 @1 @2) @3)
(vec_cond @0 (plus! @1 @3) (plus! @2 @3)))
to make the simplification only apply in case both plus operations
in the result end up simplified to a simple operand.
2020-07-31 Richard Biener <rguenther@suse.de>
* genmatch.c (expr::force_leaf): Add and initialize.
(expr::gen_transform): Honor force_leaf by passing
NULL as sequence argument to maybe_push_res_to_seq.
(parser::parse_expr): Allow ! marker on result expression
operations.
* doc/match-and-simplify.texi: Amend.
Diffstat (limited to 'gcc/doc/match-and-simplify.texi')
-rw-r--r-- | gcc/doc/match-and-simplify.texi | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/doc/match-and-simplify.texi b/gcc/doc/match-and-simplify.texi index 1df8b90..41980ac 100644 --- a/gcc/doc/match-and-simplify.texi +++ b/gcc/doc/match-and-simplify.texi @@ -361,6 +361,21 @@ Usually the types of the generated result expressions are determined from the context, but sometimes like in the above case it is required that you specify them explicitely. +Another modifier for generated expressions is @code{!} which +tells the machinery to only consider the simplification in case +the marked expression simplified to a simple operand. Consider +for example + +@smallexample +(simplify + (plus (vec_cond:s @@0 @@1 @@2) @@3) + (vec_cond @@0 (plus! @@1 @@3) (plus! @@2 @@3))) +@end smallexample + +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. + As intermediate conversions are often optional there is a way to avoid the need to repeat patterns both with and without such conversions. Namely you can mark a conversion as being optional |