This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: minor code-quality regression vs. 2.95
On Wed, Apr 12, 2000 at 04:08:23PM -0500, Clinton Popetz wrote:
> On Tue, Apr 11, 2000 at 09:45:41PM -0700, Zack Weinberg wrote:
> > This function:
> >
> > long long blocks (long long bytes) { return bytes / 512; }
...
> ix86_expand_branch is emitting the long long compare like this:
>
> * a < b =>
> * if (hi(a) < hi(b)) goto true;
> * if (hi(a) > hi(b)) goto false;
> * if (lo(a) < lo(b)) goto true;
>
> In the above case, the third jump can be turned into an uncoditional jump by
> cse, which means the first test/jump could be eliminated _if_ it were emitted
> directly before the last one (i.e. swap the first two statements above.)
...
> In 2.95.2, insn 16 was deleted by cse, because i386 was a cc0 port and
> cse_insn knew cc0 wasn't preserved accross insns. This allowed the
> jump pass after cse to delete jump 15 as well. In the current compiler,
> neither is deleted (because we don't have flow to know that 16 is dead.)
>
> That would be ok, because flow deletes 16 later, and jump2 deletes jump 15.
> But we can't delete insn 14 when we delete jump 15, because we can't rely on
> the REG_DEAD notes after scheduling (see the comment in delete_computation.)
> Since insn 14 can't go, we can't delete jump 17 and invert jump 13.
I do agree that it would be nice if life info remained valid all the way
through the optimizer. However, in this case I'm wondering why we go for
the full comparison when all we want to know is if the value is negative.
a < 0 trivially optimizes to hi(a) < 0, because the low 32 bits can't
affect the sign. We could do the same for a > 0, and similar for <=
and >= (have to test low == 0 as well). That would be easy to do at
RTL generation time.
I also can't figure out how we get from 'val / 512' to ix86_expand_branch.
There's no divdi pattern, and the ashrdi patterns don't generate the
branch and addition. It must be hiding somewhere in the machine
independent code, but I don't know where.
zw