This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/19804] Missed jump threading opportunity on "else" arm of COND_EXPR
- From: "kazu at cs dot umass dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Feb 2005 06:45:18 -0000
- Subject: [Bug tree-optimization/19804] Missed jump threading opportunity on "else" arm of COND_EXPR
- References: <20050207032547.19804.kazu@cs.umass.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From kazu at cs dot umass dot edu 2005-02-07 06:45 -------
Here is a test case where a jump threading opportunity would be missed
if the change suggested in the original post were made:
void
foo (int *p)
{
if (*p != 0)
bar ();
if (*p != 0)
bar ();
}
Here is a tree dump right before the first DOM.
foo (p)
{
int D.1120;
<bb 0>:
D.1120_2 = *p_1;
if (D.1120_2 != 0) goto <L0>; else goto <L1>;
<L0>:;
bar ();
<L1>:;
D.1120_3 = *p_1;
if (D.1120_3 != 0) goto <L2>; else goto <L3>;
<L2>:;
bar ();
<L3>:;
return;
}
The change I suggested would record "D.1120_2 == 2" while following
edge from <L0> to <L2>.
Then th jump threading selection code figures out that
D.1120_3 = *p_1;
is the same as
D.1120_3 = 0;
via equality "D.1120_3 == D.1120_2".
For whatever reason, the jump threading selection code does not want to
see anything but SSA_NAME on the rhs.
At that point, DOM throws away this jump threading opportunity.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19804