public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/32239] New: optimize power in loops
@ 2007-06-07 5:10 jv244 at cam dot ac dot uk
2007-06-08 10:11 ` [Bug fortran/32239] " rguenth at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-06-07 5:10 UTC (permalink / raw)
To: gcc-bugs
Current trunk generates always a call to
_gfortran_pow_r4_i4 for this code
SUBROUTINE T(a,b,F,n)
REAL :: a,b,F(n)
INTEGER :: n
INTEGER :: i
DO i=1,n
a=a+F(i)*b**i
ENDDO
END SUBROUTINE
which could, however, be transformed by the compiler (at least in -ffast-math,
but even otherwise for Fortran) in the much more efficient equivalent code
SUBROUTINE T_opt(a,b,F,n)
REAL :: a,b,F(n)
INTEGER :: n
INTEGER :: i
REAL :: tmp
tmp=1.0
DO i=1,n
tmp=tmp*b
a=a+F(i)*tmp
ENDDO
END SUBROUTINE
I think it is a pretty common situation (just from grepping in our code, most
non-constant integer powers we have are loop indices).
--
Summary: optimize power in loops
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jv244 at cam dot ac dot uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32239
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/32239] optimize power in loops
2007-06-07 5:10 [Bug fortran/32239] New: optimize power in loops jv244 at cam dot ac dot uk
@ 2007-06-08 10:11 ` rguenth at gcc dot gnu dot org
2007-06-17 6:39 ` [Bug fortran/32239] optimize power in loops, use __builtin_powi instead of _gfortran_pow_r4_i4 jb at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-06-08 10:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2007-06-08 10:11 -------
Confirmed. Instead of calls to _gfortran_pow_r4_i4, gfortran should use
__builtin_powi in this case. __builtin_powi is either expanded inline or
implemented by the libgcc powi function which looks like
TYPE
NAME (TYPE x, int m)
{
unsigned int n = m < 0 ? -m : m;
TYPE y = n % 2 ? x : 1;
while (n >>= 1)
{
x = x * x;
if (n % 2)
y = y * x;
}
return m < 0 ? 1/y : y;
}
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-06-08 10:11:40
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32239
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/32239] optimize power in loops, use __builtin_powi instead of _gfortran_pow_r4_i4
2007-06-07 5:10 [Bug fortran/32239] New: optimize power in loops jv244 at cam dot ac dot uk
2007-06-08 10:11 ` [Bug fortran/32239] " rguenth at gcc dot gnu dot org
@ 2007-06-17 6:39 ` jb at gcc dot gnu dot org
2007-06-17 11:40 ` patchapp at dberlin dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jb at gcc dot gnu dot org @ 2007-06-17 6:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jb at gcc dot gnu dot org 2007-06-17 06:39 -------
Assigning to myself, this should be easy to fix.
--
jb at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jb at gcc dot gnu dot org
AssignedTo|unassigned at gcc dot gnu |jb at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-06-08 10:11:40 |2007-06-17 06:39:39
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32239
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/32239] optimize power in loops, use __builtin_powi instead of _gfortran_pow_r4_i4
2007-06-07 5:10 [Bug fortran/32239] New: optimize power in loops jv244 at cam dot ac dot uk
2007-06-08 10:11 ` [Bug fortran/32239] " rguenth at gcc dot gnu dot org
2007-06-17 6:39 ` [Bug fortran/32239] optimize power in loops, use __builtin_powi instead of _gfortran_pow_r4_i4 jb at gcc dot gnu dot org
@ 2007-06-17 11:40 ` patchapp at dberlin dot org
2007-06-25 19:53 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: patchapp at dberlin dot org @ 2007-06-17 11:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from patchapp at dberlin dot org 2007-06-17 11:40 -------
Subject: Bug number PR32239
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-06/msg01172.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32239
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/32239] optimize power in loops, use __builtin_powi instead of _gfortran_pow_r4_i4
2007-06-07 5:10 [Bug fortran/32239] New: optimize power in loops jv244 at cam dot ac dot uk
` (2 preceding siblings ...)
2007-06-17 11:40 ` patchapp at dberlin dot org
@ 2007-06-25 19:53 ` burnus at gcc dot gnu dot org
2007-07-01 16:24 ` jb at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-06-25 19:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2007-06-25 19:52 -------
"At the moment the vectorizer only vectorizes builtin_pow if the exponent is
either 2 or 0.5. whereas if we expand constant exponents in the gfortran
frontend (gfc_conv_cst_int_power) it vectorizes for other constant integer
powers as well"
I've filled PR middle-end/32503 for this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32239
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/32239] optimize power in loops, use __builtin_powi instead of _gfortran_pow_r4_i4
2007-06-07 5:10 [Bug fortran/32239] New: optimize power in loops jv244 at cam dot ac dot uk
` (3 preceding siblings ...)
2007-06-25 19:53 ` burnus at gcc dot gnu dot org
@ 2007-07-01 16:24 ` jb at gcc dot gnu dot org
2007-07-02 16:21 ` jb at gcc dot gnu dot org
2007-07-02 20:46 ` jb at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: jb at gcc dot gnu dot org @ 2007-07-01 16:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jb at gcc dot gnu dot org 2007-07-01 16:24 -------
Subject: Bug 32239
Author: jb
Date: Sun Jul 1 16:24:38 2007
New Revision: 126175
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126175
Log:
gcc/fortran:
2007-07-01 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/32239
* trans-expr.c (gfc_conv_power_op): Use builtin_powi for
real**int4 powers.
* f95-lang.c (gfc_init_builtin_functions): Add builtin_powi to the
builtins table.
libgfortran:
2007-07-01 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/32239
* Makefile.am: Don't generate real**int4 pow functions.
* gfortran.map: Remove real**int4 pow symbols.
* Makefile.in: Regenerated.
testsuite
2007-07-01 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/32239
* gfortran.fortran-torture/execute/intrinsic_fraction_exponent.f90
(test_4): Use proper test for floating point equality.
(test_8): Likewise.
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/f95-lang.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_fraction_exponent.f90
trunk/libgfortran/ChangeLog
trunk/libgfortran/Makefile.am
trunk/libgfortran/Makefile.in
trunk/libgfortran/gfortran.map
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32239
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/32239] optimize power in loops, use __builtin_powi instead of _gfortran_pow_r4_i4
2007-06-07 5:10 [Bug fortran/32239] New: optimize power in loops jv244 at cam dot ac dot uk
` (4 preceding siblings ...)
2007-07-01 16:24 ` jb at gcc dot gnu dot org
@ 2007-07-02 16:21 ` jb at gcc dot gnu dot org
2007-07-02 20:46 ` jb at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: jb at gcc dot gnu dot org @ 2007-07-02 16:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jb at gcc dot gnu dot org 2007-07-02 16:21 -------
Subject: Bug 32239
Author: jb
Date: Mon Jul 2 16:21:37 2007
New Revision: 126215
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126215
Log:
Forgot to delete these during yesterdays commit.
2007-07-02 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/32239
* generated/pow_r*_i4.c: Removed.
Removed:
trunk/libgfortran/generated/pow_r10_i4.c
trunk/libgfortran/generated/pow_r16_i4.c
trunk/libgfortran/generated/pow_r4_i4.c
trunk/libgfortran/generated/pow_r8_i4.c
Modified:
trunk/libgfortran/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32239
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/32239] optimize power in loops, use __builtin_powi instead of _gfortran_pow_r4_i4
2007-06-07 5:10 [Bug fortran/32239] New: optimize power in loops jv244 at cam dot ac dot uk
` (5 preceding siblings ...)
2007-07-02 16:21 ` jb at gcc dot gnu dot org
@ 2007-07-02 20:46 ` jb at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: jb at gcc dot gnu dot org @ 2007-07-02 20:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jb at gcc dot gnu dot org 2007-07-02 20:46 -------
Closing as Fortran FE is fixed. There is 32503 for better vectorization of
builtin_powi, and if we want the strength reduction optimization from comment
#0 a new missed-optimization PR should be filed against the middle-end (or
tree-optimization).
--
jb at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32239
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-07-02 20:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-07 5:10 [Bug fortran/32239] New: optimize power in loops jv244 at cam dot ac dot uk
2007-06-08 10:11 ` [Bug fortran/32239] " rguenth at gcc dot gnu dot org
2007-06-17 6:39 ` [Bug fortran/32239] optimize power in loops, use __builtin_powi instead of _gfortran_pow_r4_i4 jb at gcc dot gnu dot org
2007-06-17 11:40 ` patchapp at dberlin dot org
2007-06-25 19:53 ` burnus at gcc dot gnu dot org
2007-07-01 16:24 ` jb at gcc dot gnu dot org
2007-07-02 16:21 ` jb at gcc dot gnu dot org
2007-07-02 20:46 ` jb 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).