This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/18046] Missed jump threading optimization
- From: "law at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Sep 2008 21:55:34 -0000
- Subject: [Bug tree-optimization/18046] Missed jump threading optimization
- References: <bug-18046-280@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #13 from law at redhat dot com 2008-09-23 21:55 -------
Subject: Re: Missed jump threading optimization
steven at gcc dot gnu dot org wrote:
> ------- Comment #12 from steven at gcc dot gnu dot org 2008-09-21 13:58 -------
> tree PRE now *does* handle the partially redundant global variable load. This
> is the .final_cleanup dump:
>
>
> ;; Function bar (bar)
>
> bar ()
> {
> int prephitmp.13;
>
> <bb 2>:
> prephitmp.13 = i;
> switch (prephitmp.13) <default: <L1>, case 0: <L0>>
>
> <L0>:
> foo ();
> prephitmp.13 = i;
>
> <L1>:
> switch (prephitmp.13) <default: <L5>, case 0: <L4>>
>
> <L4>:
> foo (); [tail call]
>
> <L5>:
> return;
>
> }
>
>
> But we still miss the jump threading opportunity.
>
Thanks for the update. One blocking issue out of the way....
Things have changed a lot since that original bug report. I believe the
best solution for this particular case is to lower the switch statements
early enough to expose the conditionals to DOM & VRP.
The 2nd best approach would be to extend VRP to create a range for the
default case of a SWITCH and extend the jump threading code in
tree-vrp.c to handle switch statements (they're currently ignored). The
biggest difficulty here would be to avoid dropping to varying too
quickly. I think you'd want to sort the cases, then build up a range
containing all the cases. If you get a gap in the range, you drop to
varying. If after extracting all the ranges you haven't dropped to
varying, then you invert the range and create the appropriate ASSERT_EXPRs.
I'm not currently working on either solution.
jeff
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18046