On Sun, Oct 01, 2017 at 09:22:56AM -0600, Jeff Law wrote:
> 
> A short while ago Martin Liska posted a patch that lowered certain
> switch statements into cascading conditionals.
> 
> His work tripped two regressions in the testsuite, both cases where we
> did not optimize as well as we should have.
> 
> Upon investigation I realized a simple improvement to DOM would fix
> things up.  Further testing showed that the situation occurred
> reasonably often in practice and that the situation did occur even when
> VRP was enabled.
> 
> What we want to do is detect cases where we have something like this in
> the expression hash table
> 
> TRUE = (i <= 1)
> 
> And we're presented with the condition we want to optimize like (i >= 1)
> 
> The only value of i that satisfies both is i == 1  So we can change the
> conditional to (i == 1).
> 
> The simplified conditional is useful because it exposes a constant in
> one arm of the conditional which we can propagate.  Furthermore the
> equality test is easier for tree-ssa-uninit.c to consume.
> 
> The implementation is pretty simple.  For  X GE/LE Y we lookup X LE/GE Y
> and if we get a hit then we know we can optimize the conditional to X ==
> Y.  If Y is a constant, we can handle GT/LT with trivial canonicalization.
> 
> The testcase I've added is potentially overly simplistic -- it'll likely
> be compromised by work from Aldy or Andrew at some point.   We'll likely
> have to reduce a new testcase at that time.

Wouldn't testing this with the gimple fe make this much less of an
issue?

Thanks

Trev

Reply via email to