public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/34703]  New: (Unsafe) optization of IF(A>B/C) as IF(A*C>B)
@ 2008-01-07 15:56 dominiq at lps dot ens dot fr
  2008-01-07 17:26 ` [Bug tree-optimization/34703] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-01-07 15:56 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug tree-optimization/34703] (Unsafe) optization of IF(A>B/C) as IF(A*C>B)
  2008-01-07 15:56 [Bug tree-optimization/34703] New: (Unsafe) optization of IF(A>B/C) as IF(A*C>B) dominiq at lps dot ens dot fr
@ 2008-01-07 17:26 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-07 17:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-01-07 16:57 -------
-ffinite-math-only is not enoug - that only assumes input operands are never
Inf or Nan and results of operations in the source are not Inf or Nan.  But
as you say you cannot guarantee that RADIUS * 100.0 does not overflow, so
this transformation is invalid.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-07 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-07 15:56 [Bug tree-optimization/34703] New: (Unsafe) optization of IF(A>B/C) as IF(A*C>B) dominiq at lps dot ens dot fr
2008-01-07 17:26 ` [Bug tree-optimization/34703] " rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).