On 10/21/2015 06:05 AM, Hans-Peter Nilsson wrote:
On Tue, 20 Oct 2015, Jeff Law wrote:
On 10/20/2015 06:03 PM, Hans-Peter Nilsson wrote:
I have no idea whether there's an actual bug related to the
patch or something "just waiting to happen" and 16-bit-offsets
just too close to the limits. Brief inspection of the generated
assembly-code is, well, "inconclusive". Also, I'm travelling at
the moment.
Feel free to pass it along when you get back.
Thanks. Diffstat says the r228974 version is 104 lines less, so
it's not obvious at *that* level and likely looks like an
improvement except for the breakage and stretched jumptables.
I'll open a proper bug-report soonish when less rushed.
Note that r228974 strictly reduces the number of jump threading paths we
optimize with the FSM bits. Essentially it's rejecting cases where
threading the jump will result in an irreducible loop unless it's able
to remove a multi-way branch in the loop.
Getting larger code would be a bit of a surprise (due to block
duplication jump threading often increases code size), but certainly
isn't impossible. I certainly had cases where the FSM bits would create
an irreducible loop, which was then later made reducible by other
transformations. Those two-stage kinds of optimizations won't occur
anymore.
The other possibility is by keeping the loop structure sane, we may be
getting other loop optimizations such as LICM or strength reduction
which might be making things larger.
JFTR, it's worthwhile to check that we're not missing something
that takes care of "all else equal, keep the target close to the
jumptable". If we do miss that, that's an obvious enhancement
more or less for all targets. If we already have that, there's
likely a bug.
Jump threading doesn't really have that concept as its occurring much
earlier in the optimization pipeline.
It does try to avoid useless churn of the CFG and SSA graph, which I've
noticed is generally good at keeping things from moving around
unnecessarily.
But again, when you've got the time, pass along a testcase. I'm happy
to look at it in detail.
Jeff