This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
PR java/18931: jar -> .so optimization problem
- From: Andrew Haley <aph at redhat dot com>
- To: gcc-patches at hcc dot gnu dot org dot cambridge dot redhat dot com, java-patches at gcc dot gnu dot org
- Date: Fri, 17 Dec 2004 15:06:40 +0000
- Subject: PR java/18931: jar -> .so optimization problem
This is an ICE in copy_to_mode_reg that is caused by a front end bug.
We're rather cavalier about types in the bytecode front end, in this
case loading from a parameter of type boolean into an int without any
conversion.
Also, we were using NOP_EXPRs rather than CONVERT_EXPRs when doing
integral type conversions. I'm pretty sure this is wrong too.
Andrew.
2004-12-17 Andrew Haley <aph@redhat.com>
* typeck.c (convert): Use a CONVERT_EXPR when converting to
BOOLEAN_TYPE or CHAR_TYPE.
(convert_to_boolean, convert_to_char) : Remove.
* convert.h (convert_to_boolean, convert_to_char) : Remove.
* expr.c (expand_load_internal): Do type conversion if type is not
as required.
Index: convert.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/convert.h,v
retrieving revision 1.6
diff -p -2 -c -r1.6 convert.h
*** convert.h 9 Jan 2003 23:16:50 -0000 1.6
--- convert.h 17 Dec 2004 14:43:33 -0000
*************** Boston, MA 02111-1307, USA. */
*** 21,26 ****
/* Written by Jeffrey Hsu <hsu@cygnus.com> */
- extern tree convert_to_boolean (tree, tree);
- extern tree convert_to_char (tree, tree);
extern tree convert_to_integer (tree type, tree expr);
extern tree convert_to_real (tree type, tree expr);
--- 21,24 ----
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.214
diff -p -2 -c -r1.214 expr.c
*** expr.c 28 Nov 2004 06:44:19 -0000 1.214
--- expr.c 17 Dec 2004 14:43:33 -0000
*************** expand_load_internal (int index, tree ty
*** 1330,1333 ****
--- 1330,1336 ----
Hopefully this all gets optimized out. */
copy = build_decl (VAR_DECL, NULL_TREE, type);
+ if (INTEGRAL_TYPE_P (type)
+ && TREE_TYPE (copy) != TREE_TYPE (var))
+ var = convert (type, var);
java_add_local_var (copy);
java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (var), copy, var));
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/typeck.c,v
retrieving revision 1.73
diff -p -2 -c -r1.73 typeck.c
*** typeck.c 25 Nov 2004 03:46:41 -0000 1.73
--- typeck.c 17 Dec 2004 14:43:34 -0000
*************** convert (tree type, tree expr)
*** 130,135 ****
if (code == VOID_TYPE)
return build1 (CONVERT_EXPR, type, expr);
! if (code == BOOLEAN_TYPE)
! return fold (convert_to_boolean (type, expr));
if (code == INTEGER_TYPE)
{
--- 130,135 ----
if (code == VOID_TYPE)
return build1 (CONVERT_EXPR, type, expr);
! if (code == BOOLEAN_TYPE || code == CHAR_TYPE)
! return fold (build1 (CONVERT_EXPR, type, expr));
if (code == INTEGER_TYPE)
{
*************** convert (tree type, tree expr)
*** 152,157 ****
if (code == REAL_TYPE)
return fold (convert_to_real (type, expr));
- if (code == CHAR_TYPE)
- return fold (convert_to_char (type, expr));
if (code == POINTER_TYPE)
return fold (convert_to_pointer (type, expr));
--- 152,155 ----
*************** convert (tree type, tree expr)
*** 161,176 ****
- tree
- convert_to_char (tree type, tree expr)
- {
- return build1 (NOP_EXPR, type, expr);
- }
-
- tree
- convert_to_boolean (tree type, tree expr)
- {
- return build1 (NOP_EXPR, type, expr);
- }
-
/* Return a data type that has machine mode MODE.
If the mode is an integer,
--- 159,162 ----