As reported on PR34702 I stumbled over expressions such as 

             IF ( FLOAT(NNP/NP).EQ.FLOAT(NNP)/XNP ) THEN

or 

              IF (RADIUS>=X(N)/100.0 .AND. RADIUS<=X(N+1)/100.0) EXIT 

which can obviously be rearranged as

             IF (XNP* FLOAT(NNP).EQ.FLOAT(NP*NNP) ) THEN

or

              IF (100.0*RADIUS>=X(N) .AND. 100.0*RADIUS<=X(N+1)) EXIT 

The first change overcome the problem in PR34702 with aermod.f90 and -mrecip,
while the second gives some speed up to gas_dyn.f90 (for large numbers of
iterations: 13% for 200000 iterations).  Such optimizations are indeed assuming
that there is no overflow (-ffinite-math-only?) and that the code is not
relying on side effects due to the division round-off
(-funsafe-math-optimizations?).

Would such an optimization make sense and be difficult to implement (with the
appropriate option(s), e.g., one or both of the above)?


-- 
           Summary: (Unsafe) optization of IF(A>B/C) as IF(A*C>B)
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dominiq at lps dot ens dot fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34703

Reply via email to