This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][match-and-simplify] Reject outermost captures


We can't really code-generate those (and thus such patterns are
simply skipped during code-gen ...).  Reject them early.

Committed to the branch.

Richard.

2014-05-20  Richard Biener  <rguenther@suse.de>

	* genmatch.c (parse_match_and_simplify): Reject outermost
	expressions that are captured or not expressions.
	* match.pd: Rewrite negate contracting patterns to avoid
	capturing the outermost expression.

Index: gcc/match.pd
===================================================================
--- gcc/match.pd	(revision 210637)
+++ gcc/match.pd	(working copy)
@@ -26,22 +26,18 @@ along with GCC; see the file COPYING3.
 /* ???  Have match_and_simplify groups guarded with common
    predicates on the outermost type?  */
 
-/* Contract negates.
-   ???  !TYPE_SATURATING condition missing.  */
+/* Contract negates.  */
 (match_and_simplify
-  (PLUS_EXPR @0 (NEGATE_EXPR @1))
-  /* Ugh, free form mixed in ... ;)  Want (if ...) instead?  */
-  if (!TYPE_SATURATING (TREE_TYPE (@0)))
-  (MINUS_EXPR @0 @1))
+  (plus @0 (negate @1))
+  if (!TYPE_SATURATING (type))
+  (minus @0 @1))
 (match_and_simplify
-  /* ???  Allow (MINUS:!TYPE_SATURATING @0 (NEGATE @1)), thus
-     type predicates on operands?  Thus also :INTEGRAL_TYPE_P
-     or @0:INTEGRAL_TYPE_P?  */
-  (MINUS @0 (NEGATE @1))
-  (PLUS @0 @1))
+  (minus @0 (negate @1))
+  if (!TYPE_SATURATING (type))
+  (plus @0 @1))
 (match_and_simplify
-  (plus@2 (negate @0) @1)
-  if (!TYPE_SATURATING (TREE_TYPE (@2)))
+  (plus (negate @0) @1)
+  if (!TYPE_SATURATING (type))
   (minus @1 @0))
 
 /* Change to even more free-form like
Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	(revision 210637)
+++ gcc/genmatch.c	(working copy)
@@ -829,6 +829,8 @@ parse_match_and_simplify (cpp_reader *r)
 	fatal ("expected 'if' or expression");
       ifexpr = parse_c_expr (r, CPP_OPEN_PAREN);
     }
+  if (match->type != operand::OP_EXPR)
+    fatal ("expected uncaptured expression");
   return new simplify (id, match, ifexpr, parse_op (r));
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]