#41 Simplification improvements

closed
Dave Grove
None
5
2012-09-21
2006-03-28
Ian Rogers
No

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
software
(described as/entitled improvements to
simplification
),
which was neither derived nor copied from any
other software,
or

(ii) that any exception to (i) is software which was
obtained under the
CPL (Common Public License),

and
(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
Ian :-)

Discussion

  • Ian Rogers
    Ian Rogers
    2006-03-28

    Newest patch to the simplifier (I've submitted a few now)

     
    Attachments
  • Dave Grove
    Dave Grove
    2006-04-01

    Logged In: YES
    user_id=1215435

    sorry for the lag; been one of this weeks. Starting
    regression tests this afternoon.

    On the switch optimization: if there are less than 8
    targets, OPT_ConvertToLowLevelIR converts switches to binary
    search trees of ifcmps.

     
  • Dave Grove
    Dave Grove
    2006-04-03

    Logged In: YES
    user_id=1215435

    passed regression tests; as soon as developer cvs access is
    working again I will check it in.

     
  • Dave Grove
    Dave Grove
    2006-04-05

    Logged In: YES
    user_id=1215435

    cvs finally back up; commited patch.