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: an optimization and a triviality


More trivial patches.  The first one I've posted earlier
- it does some constant folding even when we can't call fold.

The second one is so trivial it's embarassing - but it's the
principle of not using resources you don't need.

2001-12-03  Per Bothner  <per@bothner.com>

	* parse.y (patch_binop):  Minor constant folding.

	* parse.y (build_current_thisn):  Shorter 'buffer'.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.328
diff -u -p -r1.328 parse.y
--- parse.y	2001/12/03 19:13:40	1.328
+++ parse.y	2001/12/04 01:22:14
@@ -8619,7 +8619,7 @@ build_current_thisn (type)
    static int saved_type_i = 0;
    static int initialized_p;
    tree decl;
-  char buffer [80];
+  char buffer [24];
    int i = 0;

    /* Register SAVED_THISN and SAVED_TYPE with the garbage collector.  */
@@ -13769,6 +13769,14 @@ patch_binop (node, wfl_op1, wfl_op2)
  	  TREE_TYPE (node) = boolean_type_node;
  	  error_found = 1;
  	  break;
+ 
}
+      else if (integer_zerop (op1))
+ 
{
+ 
   return code == TRUTH_ANDIF_EXPR ? op1 : op2;
+ 
}
+      else if (integer_onep (op1))
+ 
{
+ 
   return code == TRUTH_ANDIF_EXPR ? op2 : op1;
  	}
        /* The type of the conditional operators is BOOLEAN */
        prom_type = boolean_type_node;

-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/
2001-12-03  Per Bothner  <per@bothner.com>

	* parse.y (patch_binop):  Minor constant folding.

	* parse.y (build_current_thisn):  Shorter 'buffer'.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.328
diff -u -p -r1.328 parse.y
--- parse.y	2001/12/03 19:13:40	1.328
+++ parse.y	2001/12/04 01:22:14
@@ -8619,7 +8619,7 @@ build_current_thisn (type)
   static int saved_type_i = 0;
   static int initialized_p;
   tree decl;
-  char buffer [80];
+  char buffer [24];
   int i = 0;
 
   /* Register SAVED_THISN and SAVED_TYPE with the garbage collector.  */
@@ -13769,6 +13769,14 @@ patch_binop (node, wfl_op1, wfl_op2)
 	  TREE_TYPE (node) = boolean_type_node;
 	  error_found = 1;
 	  break;
+	}
+      else if (integer_zerop (op1))
+	{
+	  return code == TRUTH_ANDIF_EXPR ? op1 : op2;
+	}
+      else if (integer_onep (op1))
+	{
+	  return code == TRUTH_ANDIF_EXPR ? op2 : op1;
 	}
       /* The type of the conditional operators is BOOLEAN */
       prom_type = boolean_type_node;

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