diff mbox

[match-and-simplify] Use multi-id for in one example

Message ID alpine.LSU.2.11.1409081223010.20733@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Sept. 8, 2014, 10:25 a.m. UTC
The following patch makes use of the new multi-id for in builtin
math fn patterns related to POW to show how we can address the
usual triplets of fnF, fn, fnL simplifications with it.  It's
still quite explicit of course.

The patch also supplies locations to some parser error calls
and removes a stray debug printf.

Committed.

Richard.

2014-09-08  Richard Biener  <rguenther@suse.de>

	* genmatch.c (parse_for): Supply location for errors, remove
	debug printf.
	* match-builtin.pd (pow transforms): Provide an example
	of multi-id for.
diff mbox

Patch

Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	(revision 215010)
+++ gcc/genmatch.c	(working copy)
@@ -2416,7 +2416,7 @@  parse_for (cpp_reader *r, source_locatio
 
       const char *id = (const char *) NODE_NAME (token->val.node.node);
       if (get_operator (id))
-	fatal ("built-in operators cannot be user defined identifiers in for");
+	fatal_at (token, "built-in operators cannot be user defined identifiers in for");
 
       user_ids.safe_push (id);
       eat_token (r, CPP_NAME);
@@ -2441,14 +2441,12 @@  parse_for (cpp_reader *r, source_locatio
       if (n_opers == 0)
 	n_opers = opers.length ();
       else if (n_opers != opers.length ())
-	fatal ("All user-defined identifiers must have same number of operator substitutions");
+	fatal_at (token, "All user-defined identifiers must have same number of operator substitutions");
       eat_token (r, CPP_CLOSE_PAREN);
     }	  
 
   if (user_ids.length () == 0)
-    fatal ("for requires at least one user-defined identifier");
-
-  fprintf (stderr, "Supriya\n");
+    fatal_at (token, "for requires at least one user-defined identifier");
 
   vec<simplify *> for_simplifiers = vNULL;
   while (1)
@@ -2460,7 +2458,7 @@  parse_for (cpp_reader *r, source_locatio
     }
 
   if (for_simplifiers.length () == 0)
-    fatal ("no pattern defined in for");
+    fatal_at (token, "no pattern defined in for");
 
   unsigned n_ids = user_ids.length ();
 
Index: gcc/match-builtin.pd
===================================================================
--- gcc/match-builtin.pd	(revision 215010)
+++ gcc/match-builtin.pd	(working copy)
@@ -54,8 +54,12 @@  along with GCC; see the file COPYING3.
 (simplify
  (BUILT_IN_POW real_onep@0 @1)
  @0)
+
+(for POW (BUILT_IN_POWF BUILT_IN_POW BUILT_IN_POWL)
+     SQRT (BUILT_IN_SQRTF BUILT_IN_SQRT BUILT_IN_SQRTL)
+     CBRT (BUILT_IN_CBRTF BUILT_IN_CBRT BUILT_IN_CBRTL)
 (simplify
- (BUILT_IN_POW @0 REAL_CST@1)
+ (POW @0 REAL_CST@1)
  (with { REAL_VALUE_TYPE c = TREE_REAL_CST (@1); }
   /* Optimize pow(x,0.0) = 1.0.  */
   (if (REAL_VALUES_EQUAL (c, dconst0))
@@ -69,14 +73,15 @@  along with GCC; see the file COPYING3.
   /* Optimize pow(x,0.5) = sqrt(x).  */
   (if (flag_unsafe_math_optimizations
        && REAL_VALUES_EQUAL (c, dconsthalf))
-   (BUILT_IN_SQRT @0))
+   (SQRT @0))
   /* Optimize pow(x,1.0/3.0) = cbrt(x).  */
   (with
     { const REAL_VALUE_TYPE dconstroot
         = real_value_truncate (TYPE_MODE (type), dconst_third ()); }
     (if (flag_unsafe_math_optimizations
 	 && REAL_VALUES_EQUAL (c, dconstroot))
-     (BUILT_IN_CBRT @0)))))
+     (CBRT @0))))))
+
 /* Strip sign ops from even integer powers.
    ???  The code in builtins.c manages to perform this recursively
    through the whole expression in arg0 of pow.  */