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 to fold in convert_ieee_real_to_integer


While looking into how constant fields propagate, I found that
convert_ieee_real_to_integer doesn't constant-fold.  I think it
should.  Andrew, I believe this is your code, so please take a
look.  You might also want to re-format.  Normally, we do fold
fold (build (...)) rather than build (...., fold (...)), so I
should move the fold calls (pysically, not logically).

(I haven't run the test-suite yet, because libstc++ doesn't build
for me.  I'll do that before a check-in.)

	* typeck.c (convert_ieee_real_to_integer):  Add constant-folding.

--
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/typeck.c,v
retrieving revision 1.51
diff -u -p -r1.51 typeck.c
--- typeck.c	4 Aug 2002 22:45:31 -0000	1.51
+++ typeck.c	6 Sep 2002 19:02:48 -0000
@@ -85,23 +85,23 @@ convert_ieee_real_to_integer (type, expr
   expr = save_expr (expr);
 
   result = build (COND_EXPR, type,
-		  build (NE_EXPR, boolean_type_node, expr, expr),
+		  fold (build (NE_EXPR, boolean_type_node, expr, expr)),
 		  convert (type, integer_zero_node),
 		  convert_to_integer (type, expr));
 		  
   result = build (COND_EXPR, type, 
-		  build (LE_EXPR, boolean_type_node, expr, 
-			 convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type))),
+		  fold (build (LE_EXPR, boolean_type_node, expr, 
+			       convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type)))),
 		  TYPE_MIN_VALUE (type),
-		  result);
+		  fold (result));
 
   result = build (COND_EXPR, type,
-		  build (GE_EXPR, boolean_type_node, expr, 
-			 convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type))),	
+		  fold (build (GE_EXPR, boolean_type_node, expr, 
+			 convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type)))),	
 		  TYPE_MAX_VALUE (type),
-		  result);
+		  fold (result));
 
-  return result;
+  return fold (result);
 }  
 
 /* Create an expression whose value is that of EXPR,

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