This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
[Bug java/15525] New: suggestion to enable cast elimination
- From: "tromey at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: java-prs at gcc dot gnu dot org
- Date: 18 May 2004 20:42:30 -0000
- Subject: [Bug java/15525] New: suggestion to enable cast elimination
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Diego pointed out on irc today that we could eliminate some
casts by changing the java gimplifier a bit to allow CCP to
do the work for us.
Eg, consider this idiom:
if (! (x instanceof foo))
return false;
foo self = (foo) x;
We could generate code like so:
int tmp_1 = 0;
if (! (_Jv_IsInstanceOf (x, &foo.class)) return 0;
else tmp_1 = 1;
foo self = tmp_1 ? (foo) x : _Jv_CheckCast (x, &foo.class);
We could do this when generating code for "instanceof" along these lines:
_Jv_IsInstanceOf(...) ? ({ tmp_1 = 1; 1 }) : 0
With this approach, redundant calls to _Jv_CheckCast would be
automatically eliminated. Perhaps then we could have an extra
pass to get rid of any remaining temporary variables that we introduced.
--
Summary: suggestion to enable cast elimination
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tromey at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15525