This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/32044] [4.3/4.4 Regression] final value replacement too aggressive for e.g. targets with no native div/mod insns
- 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: 11 Dec 2008 00:27:35 -0000
- Subject: [Bug tree-optimization/32044] [4.3/4.4 Regression] final value replacement too aggressive for e.g. targets with no native div/mod insns
- References: <bug-32044-11706@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #60 from steven at gcc dot gnu dot org 2008-12-11 00:27 -------
IMHO I the transformation to division is not fine. I would argue this is the
core issue in this problem report.
You are right that a combination of div and mod is quite common in real-world
code. Right now, GCC can catch that when the port emits a divmod libcall by
default instead of just a div and/or a mod. However, I consider this a
separate issue.
GCC currently does not recognize div/mod or mod/div as patterns, because at the
tree level this would show up as two separate expressions (possibly with
statements between the div and mod expresssions), and expand works one
statement at a time.
Some targets (e.g. x86) call a divmod libcall by default for a div or a mod
instruction. If there is a div/mod or mod/div sequence in the code, GCC
optimizes away one of the libcalls via the REG_EQUAL notes, IIRC.
But our concern now should be to avoid this situation where gcc "invents" a div
or mod instruction in the first place.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32044