This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fix possible FP reassociation problem in simplify-rtx.c


On 11/24/05, Paolo Bonzini <bonzini@gnu.org> wrote:
This patch fixes two minor problems with simplify_plus_minus.

1) The bigger problem is the function is unsafe for floating-point
operations but it is called unconditionally from simplify_gen_binary.
We can arrange for simplify_binary_operation to call simplify_plus_minus,
so this should not be necessary.

2) A smaller problem is that the function will not always canonicalize
as much as possible.  For example, combine provides a canonical form
for (minus A (plus B C)), which is (minus (minus A B) C): instead,
simplify_plus_minus will not recognize this simplification when called
with FORCE == 0.

The solution to (1) is to remove the call to simplify_plus_minus from
simplify_binary_operation, which also allows us to remove the FORCE
argument to the function.

The solution to (2) is to make simplify_plus_minus try hard to do not
only simplifications, but also canonicalizations.  If there is something
that we can canonicalize, simplify_plus_minus will actually behave as if
(before this patch) FORCE was 1.

Bootstrapped i686-pc-linux-gnu with no build-time regression,
SPEC-tested with three iterations (there is a big improvement in bzip2
but it should be a load fluctuation).  The patch introducing the call to
simplify_plus_minus is at
http://gcc.gnu.org/ml/gcc-patches/2002-02/msg01513.html; the test
case that rth describes there is still working as desired.

Ok for mainline?

Paolo

    168.wupwise       1600   161       996*     1600   161       996*
    171.swim          3100   172      1799*     3100   169      1831*
    172.mgrid         1800   283       636*     1800   283       637*
    173.applu         2100   201      1045*     2100   202      1042*
    177.mesa                              X                         X
    178.galgel        2900   288      1009*     2900   287      1010*
    179.art           2600   427       609*     2600   424       613*
    183.equake        1300    77.3    1681*     1300    77.2    1684*
    187.facerec       1900   215       886*     1900   213       893*
    188.ammp          2200   315       700*     2200   315       697*
    189.lucas         2000   235       850*     2000   229       875*
    191.fma3d         2100   240       876*     2100   241       872*
    200.sixtrack      1100   194       566*     1100   195       565*
    301.apsi          2600   263       988*     2600   265       981*
    164.gzip          1400   160       875*     1400   159       881*
    175.vpr           1400   172       815*     1400   168       835*
    176.gcc           1100    72.2    1523*     1100    70.2    1567*
    181.mcf           1800   178      1012*     1800   175      1027*
    186.crafty        1000    97.0    1031*     1000    96.3    1039*
    197.parser        1800   205       877*     1800   203       887*
    252.eon           1300   130       999*     1300   130       998*
    253.perlbmk       1800   120      1495*     1800   120      1496*
    254.gap           1100    80.8    1362*     1100    81.0    1357*
    255.vortex        1900   145      1307*     1900   142      1337*
    256.bzip2         1500   198       757*     1500   159       944* <<<
    300.twolf         3000   239      1256*     3000   232      1292*


2005-11-23 Paolo Bonzini <bonzini@gnu.org>


        * simplify-rtx.c (simplify_plus_minus): Remove final parameter.
        Always produce an output if we can remove NEGs or canonicalize
        (minus (minus ...)) expressions.  Provide a fast path for the
        two-operand case.
        (simplify_gen_binary): Do not call simplify_plus_minus.
        (simplify_binary_operation_1): Reassociate at the end of the
        function.

This introduces a missed optimization (and so hides wrong-code PR28651). simplify_plus_minus (MINUS, SImode, op0, op1) no longer simplifies

(gdb) call debug_rtx (op0)
(plus:SI (reg/v:SI 59 [ u ])
   (const_int 4 [0x4]))
(gdb) call debug_rtx (op1)
(reg/v:SI 59 [ u ])

Dunno if this matters in practice though.

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]