public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/40106] Time increase for the Polyhedron test air.f90 due to bad optimization
Date: Mon, 31 Aug 2009 23:59:00 -0000	[thread overview]
Message-ID: <20090831235944.4365.qmail@sourceware.org> (raw)
In-Reply-To: <bug-40106-12313@http.gcc.gnu.org/bugzilla/>



------- Comment #28 from dominiq at lps dot ens dot fr  2009-08-31 23:59 -------
Following Richard Guenther's suggestion on IRC, I have tested the following
patch:

--- ../_gcc_clean/gcc/builtins.c        2009-08-31 15:07:18.000000000 +0200
+++ gcc/builtins.c      2009-09-01 01:28:09.000000000 +0200
@@ -3012,7 +3012,7 @@
       real_from_integer (&cint, VOIDmode, n, n < 0 ? -1 : 0, 0);
       if (real_identical (&c2, &cint)
          && ((flag_unsafe_math_optimizations
-              && optimize_insn_for_speed_p ()
+              /* && optimize_insn_for_speed_p () */
               && powi_cost (n/2) <= POWI_MAX_MULTS)
              || n == 1))
        {

With it I get:

[ibook-dhum] test/dbg_air% gfc -m64 -O2 -funsafe-math-optimizations air_db.f90
[ibook-dhum] test/dbg_air% time a.out > /dev/null
4.490u 0.018s 0:04.51 99.7%     0+0k 0+3io 0pf+0w

compared to

[ibook-dhum] test/dbg_air% gfc -m64 -O2 -funsafe-math-optimizations
-fno-strict-overflow air_db.f90
[ibook-dhum] test/dbg_air% time a.out > /dev/null
4.320u 0.015s 0:04.34 99.7%     0+0k 0+0io 0pf+0w

and there is no call to pow in the assembly. I think the difference is
significant; so it seems that optimize_insn_for_speed_p () is playing some role
elsewhere in the code. Note that if I replace lines 322 and 427

            mu = mu0*(T(i,j)/t02)**1.5*(t02+110.56)/(T(i,j)+110.56)

with

            mu = mu0*sqrt((T(i,j)/t02)**3)*(t02+110.56)/(T(i,j)+110.56)

or

            mu =
mu0*sqrt((T(i,j)/t02))*(T(i,j)/t02)*(t02+110.56)/(T(i,j)+110.56)

there is no call to pow and the code is slightly faster with
-fno-strict-overflow

[ibook-dhum] test/dbg_air% gfc -m64 -O2 -funsafe-math-optimizations
-fno-strict-overflow air_db_1.f90
[ibook-dhum] test/dbg_air% time a.out > /dev/null
4.323u 0.015s 0:04.34 99.7%     0+0k 0+0io 0pf+0w
[ibook-dhum] test/dbg_air% gfc -m64 -O2 -funsafe-math-optimizations
air_db_1.f90
[ibook-dhum] test/dbg_air% time a.out > /dev/null
4.527u 0.016s 0:04.55 99.5%     0+0k 0+0io 0pf+0w

The original air.f90 compiled with -fwhole-file gives

[ibook-dhum] lin/test% gfc -m64 -O3 -ffast-math -funroll-loops
-ftree-loop-linear -fomit-frame-pointer -finline-limit=600 --param
min-vect-loop-bound=2 -fwhole-file air.f90
[ibook-dhum] lin/test% time a.out > /dev/null
8.358u 0.049s 0:08.42 99.6%     0+0k 0+8io 0pf+0w

compared to

[ibook-dhum] lin/test% gfc -m64 -O3 -ffast-math -funroll-loops
-ftree-loop-linear -fomit-frame-pointer -finline-limit=600 --param
min-vect-loop-bound=2 air.f90
[[ibook-dhum] lin/test% time a.out > /dev/null
8.273u 0.046s 0:08.32 99.8%     0+0k 0+0io 0pf+0w


-- 


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


  parent reply	other threads:[~2009-08-31 23:59 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-11 18:04 [Bug middle-end/40106] New: Time increase with inlining for the Polyhedron test air.f90 dominiq at lps dot ens dot fr
2009-05-12 11:52 ` [Bug middle-end/40106] " hubicka at gcc dot gnu dot org
2009-05-12 13:23 ` dominiq at lps dot ens dot fr
2009-05-12 14:47 ` rguenther at suse dot de
2009-05-12 16:18 ` dominiq at lps dot ens dot fr
2009-05-22 20:39 ` dominiq at lps dot ens dot fr
2009-05-22 20:41 ` dominiq at lps dot ens dot fr
2009-05-22 20:52 ` dominiq at lps dot ens dot fr
2009-07-13 15:29 ` burnus at gcc dot gnu dot org
2009-08-25 11:56 ` dominiq at lps dot ens dot fr
2009-08-25 12:01 ` [Bug middle-end/40106] Time increase " dominiq at lps dot ens dot fr
2009-08-25 12:22 ` [Bug middle-end/40106] Time increase with inlining " rguenth at gcc dot gnu dot org
2009-08-25 12:30 ` dominiq at lps dot ens dot fr
2009-08-25 12:40 ` rguenther at suse dot de
2009-08-25 12:51 ` dominiq at lps dot ens dot fr
2009-08-25 15:31 ` dominiq at lps dot ens dot fr
2009-08-25 21:25 ` [Bug middle-end/40106] Time increase for the Polyhedron test air.f90 due to bad optimization dominiq at lps dot ens dot fr
2009-08-27 21:59 ` dominiq at lps dot ens dot fr
2009-08-28  1:09 ` howarth at nitro dot med dot uc dot edu
2009-08-28  5:39 ` dominiq at lps dot ens dot fr
2009-08-28  7:19 ` dominiq at lps dot ens dot fr
2009-08-28 12:01 ` dominiq at lps dot ens dot fr
2009-08-28 12:23 ` dominiq at lps dot ens dot fr
2009-08-28 13:36 ` howarth at nitro dot med dot uc dot edu
2009-08-31 13:06 ` dominiq at lps dot ens dot fr
2009-08-31 15:04 ` dominiq at lps dot ens dot fr
2009-08-31 15:21 ` jv244 at cam dot ac dot uk
2009-08-31 15:23 ` rguenther at suse dot de
2009-08-31 23:59 ` dominiq at lps dot ens dot fr [this message]
2009-09-01  9:37 ` dominiq at lps dot ens dot fr
2009-09-03  7:10 ` [Bug middle-end/40106] [4.4/4.5 Regression] " dominiq at lps dot ens dot fr
2009-09-03 11:20 ` dominiq at lps dot ens dot fr
2009-09-06 22:15 ` rguenth at gcc dot gnu dot org
2009-09-18  8:58 ` rguenth at gcc dot gnu dot org
2009-10-15 12:49 ` jakub at gcc dot gnu dot org
2009-10-18 13:22 ` rguenth at gcc dot gnu dot org
2009-12-15 16:40 ` rguenth at gcc dot gnu dot org
2010-01-21 13:16 ` jakub at gcc dot gnu dot org
2010-02-25 17:20 ` [Bug middle-end/40106] [4.4/4.5 Regression] Weird interaction between optimize_insn_for_speed_p and -funsafe-math-optimizations dominiq at lps dot ens dot fr
2010-03-16 15:07 ` dominiq at lps dot ens dot fr
2010-03-16 15:11 ` rguenther at suse dot de
2010-03-16 15:26 ` rguenth at gcc dot gnu dot org
2010-03-16 15:50 ` dominiq at lps dot ens dot fr
2010-03-16 15:52 ` rguenther at suse dot de
2010-03-16 16:04 ` dominiq at lps dot ens dot fr
2010-03-16 16:07 ` rguenther at suse dot de
2010-03-16 16:39 ` dominiq at lps dot ens dot fr
2010-03-16 16:59 ` jakub at gcc dot gnu dot org
2010-03-16 17:14 ` dominiq at lps dot ens dot fr
2010-03-18 18:30 ` dominiq at lps dot ens dot fr
2010-03-19 10:26 ` rguenth at gcc dot gnu dot org
2010-03-19 10:35 ` rguenth at gcc dot gnu dot org
2010-03-19 15:40 ` dominiq at lps dot ens dot fr
2010-03-20 13:03 ` dominiq at lps dot ens dot fr
2010-03-20 13:21 ` dominiq at lps dot ens dot fr
2010-03-20 14:19 ` rguenther at suse dot de
2010-03-20 14:40 ` dominiq at lps dot ens dot fr
2010-03-20 15:00 ` rguenth at gcc dot gnu dot org
2010-03-20 15:12 ` rguenth at gcc dot gnu dot org
2010-03-22 10:36 ` rguenth at gcc dot gnu dot org
2010-03-22 12:38 ` rguenth at gcc dot gnu dot org
2010-03-22 12:39 ` [Bug middle-end/40106] [4.4 " rguenth at gcc dot gnu dot org
2010-03-25 17:38 ` hubicka at gcc dot gnu dot org
2010-04-30  9:01 ` jakub at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090831235944.4365.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).