[CVS 980420] Still strength-reduce bug on HP-UX!
Jeffrey A Law
law@cygnus.com
Tue Apr 21 22:12:00 GMT 1998
In message < 199804220423.VAA25101@rtl.cygnus.com >you write:
> The problem here is that check_dbra_loop is reversing a loop when it is
> not safe to do so. check_dbra_loop is confused because it assumes that
> there are always two instructions (a compare and a branch) at the end of the
> loop, but the HPPA only puts one compare-and-branch insn at the end of the
> loop.
Right. As we briefly discussed privately last week, I've always though
that code was bogus, but never sat down and tried to prove it.
Last week, I *finally* had a way to trigger this bug in check_dbra_loop
on the PA (found while working on an unrelated issue after tweaking
jump.c a little).
> I know that Jeff Law has run into this problem in a different context, and I
> know that Joern Rennecke has been working on a patch to improve this
> function which fixes some problems, but doesn't seem to fix this one.
Wild -- it's really strange to have multiple folks run into this
long standing bugs at nearly the same time.
> I stole an idea from Joern's patch, and came up with this quick solution to
> the problem, which seems to make things better without introducing any new
> problems. I haven't tried testing this patch on anything other than the
> provided example though.
>
> Tue Apr 21 21:12:48 1998 Jim Wilson <wilson@cygnus.com>
>
> * loop.c (check_dbra_loop): New locals jump, first_compare, and
> compare_and_branch. Call get_condition to set first_compare.
> Set compare_and_branch to number of compare/branch instructions.
Replace PREV_INSN (PREV_INSN (loop_end)) with first_compare.
> Replace '2' with compare_and_branch.
It looks like the right approach -- better than the hack I was using
last week. I just #if 0'd the second call to delete insn in my
local tree while working on the unrelated issue :-)
You might want to return zero if get_condition returned zero or
first_compare isn't the jump or the immediately preceeding
real instruction.
The case I'm thinking about is a non-cc0 machine which has comparison
insns. They might get moved, or something could be inserted between
the first comparison and the conditional branch (partial redundancy
elimination/lazy code motion might do that if the block with the
jump was an optimal computation point for a redundant expression).
jeff
More information about the Gcc-bugs
mailing list