This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[Java] Call "fold" in convert_ieee_real_to_integer
- From: Roger Sayle <roger at eyesopen dot com>
- To: Ranjit Mathew <rmathew at gmail dot com>
- Cc: java-patches at gcc dot gnu dot org, <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 21 Jul 2004 15:23:06 -0600 (MDT)
- Subject: [Java] Call "fold" in convert_ieee_real_to_integer
On Wed, 21 Jul 2004, Ranjit Mathew wrote:
> No, "case (int)Float.NaN:" also doesn't work.
Hi Ranjit,
Could you check whether the patch below cures the recent JACKS
failures (and "case (int)Float.Nan") for you?
This following patch has been tested on i686-pc-linux-gnu, with a full
"make bootstrap", all default languages including java, and regression
tested with a top-level "make -k check" with no new failures.
Ok for mainline if this fixes Ranjit's problems?
2004-07-21 Roger Sayle <roger@eyesopen.com>
* typeck.c (convert_ieee_real_to_integer): Call fold on the range
checking trees as they're being built.
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/typeck.c,v
retrieving revision 1.67
diff -c -3 -p -r1.67 typeck.c
*** typeck.c 20 Jul 2004 12:25:50 -0000 1.67
--- typeck.c 21 Jul 2004 18:07:54 -0000
*************** convert_ieee_real_to_integer (tree type,
*** 83,107 ****
tree result;
expr = save_expr (expr);
! result = build3 (COND_EXPR, type,
! build2 (NE_EXPR, boolean_type_node, expr, expr),
! convert (type, integer_zero_node),
! convert_to_integer (type, expr));
!
! result = build3 (COND_EXPR, type,
! build2 (LE_EXPR, boolean_type_node, expr,
! convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type))),
! TYPE_MIN_VALUE (type),
! result);
!
! result = build3 (COND_EXPR, type,
! build2 (GE_EXPR, boolean_type_node, expr,
! convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type))),
! TYPE_MAX_VALUE (type),
! result);
return result;
! }
/* Create an expression whose value is that of EXPR,
converted to type TYPE. The TREE_TYPE of the value
--- 83,110 ----
tree result;
expr = save_expr (expr);
! result = fold (build3 (COND_EXPR, type,
! fold (build2 (NE_EXPR, boolean_type_node,
! expr, expr)),
! convert (type, integer_zero_node),
! convert_to_integer (type, expr)));
!
! result = fold (build3 (COND_EXPR, type,
! fold (build2 (LE_EXPR, boolean_type_node, expr,
! convert (TREE_TYPE (expr),
! TYPE_MIN_VALUE (type)))),
! TYPE_MIN_VALUE (type),
! result));
!
! result = fold (build3 (COND_EXPR, type,
! fold (build2 (GE_EXPR, boolean_type_node, expr,
! convert (TREE_TYPE (expr),
! TYPE_MAX_VALUE (type)))),
! TYPE_MAX_VALUE (type),
! result));
return result;
! }
/* Create an expression whose value is that of EXPR,
converted to type TYPE. The TREE_TYPE of the value
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833