This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/14341] Missed comparision optimization (jump threading related)
- From: "steven at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Feb 2004 14:20:01 -0000
- Subject: [Bug optimization/14341] Missed comparision optimization (jump threading related)
- References: <20040229062941.14341.pinskia@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From steven at gcc dot gnu dot org 2004-02-29 14:19 -------
Tree dump after DCE1:
t ()
{
int x;
int i;
int T.0;
# BLOCK 0
# PRED: ENTRY (fallthru)
i_2 = 0;
goto <bb 2> (<L1>);
# SUCC: 2 (fallthru)
# BLOCK 1
# PRED: 2 (true)
<L0>:;
T.0_3 = i_1 <= 99999999;
f (T.0_3);
i_4 = i_1 + 1;
# SUCC: 2 (fallthru)
# BLOCK 2
# PRED: 1 (fallthru) 0 (fallthru)
# i_1 = PHI <i_2(0), i_4(1)>;
<L1>:;
if (i_1 <= 99999999) goto <L0>; else goto <L2>;
# SUCC: 3 (false) 1 (true)
# BLOCK 3
# PRED: 2 (false)
<L2>:;
return;
# SUCC: EXIT
}
The dominator tree looks like this:
bb0
|
bb2 (contains loop exit condition "i < 100000000")
|\
| \
| \
| bb1 (contains "f(i < 100000000);")
|
bb3
So the loop exit condition dominates the function call and we should be able
to optimize that test.
Tree dump after DOM1:
t ()
{
int x;
int i;
int T.0;
# BLOCK 0
# PRED: ENTRY (fallthru)
i_5 = 0;
i_6 = 0;
# SUCC: 1 (fallthru)
# BLOCK 1
# PRED: 0 (fallthru) 1 (true)
# i_1 = PHI <0(0), i_7(1)>;
<L0>:;
T.0_3 = i_1 <= 99999999;
f (T.0_3);
i_7 = i_1 + 1;
if (i_7 <= 99999999) goto <L0>; else goto <L2>;
# SUCC: 2 (false) 1 (true)
# BLOCK 2
# PRED: 1 (false)
<L2>:;
return;
# SUCC: EXIT
}
The dominator tree looks like this:
bb0
|
bb1 (contains loop exit condition "i < 100000000"
| and "f(i < 100000000);")
|
bb3
So the loop exit condition no longer dominates the function call, and we lose.
So perhaps we are threading jumps too early.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14341