We're currently missing a number of simplification
cases such as:
z = x & x; // z = x is simpler
z = x - x; // z = 0 is simpler
z = LONG_CMP x, x; // z = 0 is simpler
These cases are missed as we're normally just looking
for constant operands at simplification time, and this
patch improves this to consider some cases with similar
operands. Floating point cases are ignored due to how
they handle NaN (as we're never fpstrict does this
matter?). I've also added a case for LONG_COND_MOVE
being simplified to a BOOLEAN_CMP, but this may mean we
need some new BURS rules.
Branch simplification would only simplify a subset of
ifcmp2 cases if all comparison results were known. For
ifcmp, it too wouldn't simplify cases with similar
operands such as:
if x==x ...
This patch fixes this. It also adds some simplification
of tableswitch and lookupswitch operations, so that
when the number of targets is 0 or 1 we turn the switch
into an ifcmp. We should probably take this further,
and when the number of matches is > 1 perform ifcmps
for likely switch targets.
The patch has been tested on a development build and
SpecJVM, but it probably wants a nice big regression test.
STATEMENT OF ORIGIN FOR A SINGLE CONTRIBUTOR
I, Ian Rogers:
(a) represent that either:
(i) I am the only author and owner of the contributed
(described as/entitled improvements to
which was neither derived nor copied from any
(ii) that any exception to (i) is software which was
obtained under the
CPL (Common Public License),
(b) hereby agree to license this contributed software
under the CPL.
Prizes for guessing why I want to simplify cases of:
z = x^x and
z = x&x