public inbox for java-prs@sourceware.org help / color / mirror / Atom feed
From: "tromey at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: java-prs@gcc.gnu.org Subject: [Bug java/15525] suggestion to enable cast elimination Date: Thu, 02 Sep 2004 01:39:00 -0000 [thread overview] Message-ID: <20040902013911.4361.qmail@sourceware.org> (raw) In-Reply-To: <20040518204228.15525.tromey@gcc.gnu.org> ------- Additional Comments From tromey at gcc dot gnu dot org 2004-09-02 01:39 ------- Here's my test case. This is idiomatic Java code, the cast is checked but the check is completely redundant and can be eliminated in theory; that's the goal. I compiled with: gcj -c -O3 -fdump-tree-all q.java { int f; public boolean equals(Object x) { if (! (x instanceof q)) return false; q v = (q) x; return f == v.f; } } Before the patch, I seethis in q.java.t60.vars: ;; Function q.equals(java.lang.Object) (_ZN1q6equalsEPN4java4lang6ObjectE) q.equals(java.lang.Object) (this, x) { int T.2; <bb 0>: if (_Jv_IsInstanceOf (x, &q.class) == 0) goto <L4>; else goto <L1>; <L4>:; T.2 = 0; goto <bb 2> (<L2>); <L1>:; T.2 = this->f == _Jv_CheckCast (&q.class, x)->f; <L2>:; return T.2; } ;; Function () (_ZN1qC1Ev) () (this) { <bb 0>: <init> (this) [tail call]; return; } After the patch, q.java.t63.vars: ;; Function q.equals(java.lang.Object) (_ZN1q6equalsEPN4java4lang6ObjectE) q.equals(java.lang.Object) (this, x) { struct q * iftmp.10; int T.6; boolean T.3; <bb 0>: T.3 = _Jv_IsInstanceOf (x, &q.class); if (x == 0B || !T.3) goto <L11>; else goto <L1>; <L11>:; T.6 = 0; goto <bb 7> (<L8>); <L1>:; if (x != 0B) goto <L2>; else goto <L12>; <L12>:; iftmp.10 = 0B; goto <bb 6> (<L7>); <L2>:; if (T.3) goto <L3>; else goto <L4>; <L3>:; iftmp.10 = (struct q *) x; goto <bb 5> (<L5>); <L4>:; _Jv_ThrowCast (&q.class, x); <L5>:; <L7>:; T.6 = this->f == iftmp.10->f; <L8>:; return T.6; } ;; Function () (_ZN1qC1Ev) () (this) { <bb 0>: <init> (this) [tail call]; return; } This is an improvement, since we've eliminated an InstanceOf (the patch works by breaking CheckCast into explicit InstanceOf + ThrowCast; you won't see the redundant InstanceOf in the first dump). With VRP we could also remove the dead call to ThrowCast. This call is only reached from <L2>, and note earlier that T.3 is never 0. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15525
next prev parent reply other threads:[~2004-09-02 1:39 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-05-18 20:42 [Bug java/15525] New: " tromey at gcc dot gnu dot org 2004-05-18 21:08 ` [Bug java/15525] " pinskia at gcc dot gnu dot org 2004-05-20 19:40 ` dnovillo at gcc dot gnu dot org 2004-08-27 20:55 ` tromey at gcc dot gnu dot org 2004-09-02 1:39 ` tromey at gcc dot gnu dot org [this message] 2005-03-09 9:04 ` pinskia at gcc dot gnu dot org 2005-05-01 0:57 ` tromey at gcc dot gnu dot org [not found] <bug-15525-8172@http.gcc.gnu.org/bugzilla/> 2015-10-20 15:07 ` aph at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040902013911.4361.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=java-prs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).