diff mbox

[4/n] Merge from match-and-simplify, hook into fold-const.c

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

Commit Message

Richard Biener Oct. 17, 2014, 8:42 a.m. UTC
On Fri, 17 Oct 2014, Richard Biener wrote:

> On Thu, 16 Oct 2014, Sebastian Pop wrote:
> 
> > Richard Biener wrote:
> > > To give you an example how it looks like, the following code is
> > > generated for
> > > 
> > > /* fold_negate_exprs convert - (~A) to A + 1.  */
> > > (simplify
> > >  (negate (bit_not @0))
> > >  (if (INTEGRAL_TYPE_P (type))
> > >   (plus @0 { build_int_cst (TREE_TYPE (@0), 1); } )))
> > > 
> > > tree
> > > generic_simplify (enum tree_code code, tree type ATTRIBUTE_UNUSED, tree op0)
> > 
> > I wonder why ATTRIBUTE_UNUSED is generated for used parameters.
> 
> I've added them for the initial patch set because without any patterns
> defined (just 1/n and 2/n) only one of the parameters will be used.
> 
> Consider them removed again once we have enough patterns to make
> bootstrap happy after that.
> 
> > > {
> > >   if ((op0 && TREE_SIDE_EFFECTS (op0)))
> > >     return NULL_TREE;
> > >   switch (code)
> > >     {
> > > ...
> > >     case NEGATE_EXPR:
> > >       {
> > >         switch (TREE_CODE (op0))
> > >           {
> > >           case BIT_NOT_EXPR:
> > >             {
> > >               tree o20 = TREE_OPERAND (op0, 0);
> > >                 {
> > >                   /* #line 136 "/space/rguenther/src/svn/match-and-simplify/gcc/match.pd" */
> > >                   tree captures[2] ATTRIBUTE_UNUSED = {};
> > 
> > Same here.
> > Also, why do we allocate two elements when only captures[0] is used?
> 
> Good question - I'll have a look.

Fixed by the following - bootstrapped on x86_64-unknown-linux-gnu, 
applied.

Richard.

2014-10-17  Richard Biener  <rguenther@suse.de>

	* genmatch.c (simplify::simplify): Fix off-by-one error.
diff mbox

Patch

Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	(revision 216316)
+++ gcc/genmatch.c	(working copy)
@@ -495,7 +495,7 @@  struct simplify
       : match (match_), match_location (match_location_),
       result (result_), result_location (result_location_),
       ifexpr_vec (ifexpr_vec_), for_vec (for_vec_),
-      capture_ids (capture_ids_), capture_max (capture_ids_->size ()) {}
+      capture_ids (capture_ids_), capture_max (capture_ids_->size () - 1) {}
 
   /* The expression that is matched against the GENERIC or GIMPLE IL.  */
   operand *match;