re PR fortran/32239 (optimize power in loops, use __builtin_powi instead of _gfortran...
authorJanne Blomqvist <jb@gcc.gnu.org>
Sun, 1 Jul 2007 16:24:38 +0000 (19:24 +0300)
committerJanne Blomqvist <jb@gcc.gnu.org>
Sun, 1 Jul 2007 16:24:38 +0000 (19:24 +0300)
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.

From-SVN: r126175

gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_fraction_exponent.f90
libgfortran/ChangeLog
libgfortran/Makefile.am
libgfortran/Makefile.in
libgfortran/gfortran.map

index d76029dc748ccc2dee12dd46b6c1f9d7d5c2eff4..d0fe5d714551619143aa7317ba351d593a217158 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 2007-07-01  Janne Blomqvist  <jb@gcc.gnu.org>
 
         * trans.h: Remove decls for 64-bit allocation functions.
index 558ba0c680b63ba84a43f5c954e45b4f0399974e..314fc3796d11e62074b9ac2cde1d9cbc3d42bffc 100644 (file)
@@ -950,6 +950,13 @@ gfc_init_builtin_functions (void)
                      BUILT_IN_POW, "pow", true);
   gfc_define_builtin ("__builtin_powf", mfunc_float[1], 
                      BUILT_IN_POWF, "powf", true);
+  gfc_define_builtin ("__builtin_powil", mfunc_longdouble[2], 
+                     BUILT_IN_POWIL, "powil", true);
+  gfc_define_builtin ("__builtin_powi", mfunc_double[2], 
+                     BUILT_IN_POWI, "powi", true);
+  gfc_define_builtin ("__builtin_powif", mfunc_float[2], 
+                     BUILT_IN_POWIF, "powif", true);
+
 
   if (TARGET_C99_FUNCTIONS)
     {
index a46693587b341ae48156550a12a931db03692f27..d70e4d53888b716bc0e90b715057e13404972ffc 100644 (file)
@@ -780,9 +780,9 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
   gfc_add_block_to_block (&se->pre, &rse.pre);
 
   if (expr->value.op.op2->ts.type == BT_INTEGER
-        && expr->value.op.op2->expr_type == EXPR_CONSTANT)
+      && expr->value.op.op2->expr_type == EXPR_CONSTANT)
     if (gfc_conv_cst_int_power (se, lse.expr, rse.expr))
-      return;        
+      return;
 
   gfc_int4_type_node = gfc_get_int_type (4);
 
@@ -852,7 +852,30 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
          break;
 
        case BT_REAL:
-         fndecl = gfor_fndecl_math_powi[kind][ikind].real;
+         /* Use builtins for real ** int4.  */
+         if (ikind == 0)
+           {
+             switch (kind)
+               {
+               case 0:
+                 fndecl = built_in_decls[BUILT_IN_POWIF];
+                 break;
+               
+               case 1:
+                 fndecl = built_in_decls[BUILT_IN_POWI];
+                 break;
+
+               case 2:
+               case 3:
+                 fndecl = built_in_decls[BUILT_IN_POWIL];
+                 break;
+
+               default:
+                 gcc_unreachable ();
+               }
+           }
+         else
+           fndecl = gfor_fndecl_math_powi[kind][ikind].real;
          break;
 
        case BT_COMPLEX:
index 2a7786ce1f908dcb2316c4d4507f205180a0737c..6a556cd57b8ca183fbbdcb181a5e9549ce5c060e 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2007-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/32554
index a22d0b9f50ab67b1511b8a0ad7af95d7102315e9..c469cb4340b33ccab1645d1480b90a67909cbd2f 100644 (file)
@@ -66,7 +66,7 @@ if (z .gt. 0) then
 else
   y = (y / 2.) * (2. ** (z + 1))
 end if
-if (abs (x - y) .gt. abs(x * 1e-6)) call abort()
+if (abs (x - y) .gt. spacing (max (abs (x), abs (y)))) call abort()
 end
 
 subroutine test_8(x)
@@ -79,6 +79,6 @@ if (z .gt. 0) then
 else
   y = (y / 2._8) * (2._8 ** (z + 1))
 end if
-if (abs (x - y) .gt. abs(x * 1e-6)) call abort()
+if (abs (x - y) .gt. spacing (max (abs (x), abs(y)))) call abort()
 end
 
index ac234b5d1ebe2781d42d9886065552d967b616ac..c3d2b7165af06e2f65fd81946e3b9d12a7087ce0 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2007-07-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/32554
 
 2007-07-01  Janne Blomqvist  <jb@gcc.gnu.org>
 
-        * runtime/memory.c (internal_realloc): Use index_type for size
-        argument instead of GFC_INTEGER_4.
-        (allocate_array): Likewise.
-        (allocate): Likewise, add ifdef around unnecessary check.
-        (internal_reallo64): Remove.
-        (allocate_array64): Remove.
-        (allocate64): Remove.
-        * gfortran.map: Remove symbols for 64-bit allocation functions.
+       * runtime/memory.c (internal_realloc): Use index_type for size
+       argument instead of GFC_INTEGER_4.
+       (allocate_array): Likewise.
+       (allocate): Likewise, add ifdef around unnecessary check.
+       (internal_reallo64): Remove.
+       (allocate_array64): Remove.
+       (allocate64): Remove.
+       * gfortran.map: Remove symbols for 64-bit allocation functions.
 
 2007-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
index 049554836f45c26d70ce3f04a221a1548eb71b40..0e7453001728e4d8446a7a464a08154dd5f363fe 100644 (file)
@@ -430,10 +430,6 @@ i_pow_c = \
 $(srcdir)/generated/pow_i4_i4.c \
 $(srcdir)/generated/pow_i8_i4.c \
 $(srcdir)/generated/pow_i16_i4.c \
-$(srcdir)/generated/pow_r4_i4.c \
-$(srcdir)/generated/pow_r8_i4.c \
-$(srcdir)/generated/pow_r10_i4.c \
-$(srcdir)/generated/pow_r16_i4.c \
 $(srcdir)/generated/pow_c4_i4.c \
 $(srcdir)/generated/pow_c8_i4.c \
 $(srcdir)/generated/pow_c10_i4.c \
index 0e2106e561645ab172396a141a269a91df70a3f7..c2acb1353a7fe7217d30a8b38bf314694cf94776 100644 (file)
@@ -158,8 +158,7 @@ am__objects_25 = nearest_r4.lo nearest_r8.lo nearest_r10.lo \
        nearest_r16.lo
 am__objects_26 = set_exponent_r4.lo set_exponent_r8.lo \
        set_exponent_r10.lo set_exponent_r16.lo
-am__objects_27 = pow_i4_i4.lo pow_i8_i4.lo pow_i16_i4.lo pow_r4_i4.lo \
-       pow_r8_i4.lo pow_r10_i4.lo pow_r16_i4.lo pow_c4_i4.lo \
+am__objects_27 = pow_i4_i4.lo pow_i8_i4.lo pow_i16_i4.lo pow_c4_i4.lo \
        pow_c8_i4.lo pow_c10_i4.lo pow_c16_i4.lo pow_i4_i8.lo \
        pow_i8_i8.lo pow_i16_i8.lo pow_r4_i8.lo pow_r8_i8.lo \
        pow_r10_i8.lo pow_r16_i8.lo pow_c4_i8.lo pow_c8_i8.lo \
@@ -816,10 +815,6 @@ i_pow_c = \
 $(srcdir)/generated/pow_i4_i4.c \
 $(srcdir)/generated/pow_i8_i4.c \
 $(srcdir)/generated/pow_i16_i4.c \
-$(srcdir)/generated/pow_r4_i4.c \
-$(srcdir)/generated/pow_r8_i4.c \
-$(srcdir)/generated/pow_r10_i4.c \
-$(srcdir)/generated/pow_r16_i4.c \
 $(srcdir)/generated/pow_c4_i4.c \
 $(srcdir)/generated/pow_c8_i4.c \
 $(srcdir)/generated/pow_c10_i4.c \
@@ -1412,16 +1407,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_i8_i4.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_i8_i8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r10_i16.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r10_i4.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r10_i8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r16_i16.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r16_i4.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r16_i8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r4_i16.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r4_i4.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r4_i8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r8_i16.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r8_i4.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_r8_i8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/product_c10.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/product_c16.Plo@am__quote@
@@ -3786,34 +3777,6 @@ pow_i16_i4.lo: $(srcdir)/generated/pow_i16_i4.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pow_i16_i4.lo `test -f '$(srcdir)/generated/pow_i16_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_i16_i4.c
 
-pow_r4_i4.lo: $(srcdir)/generated/pow_r4_i4.c
-@am__fastdepCC_TRUE@   if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pow_r4_i4.lo -MD -MP -MF "$(DEPDIR)/pow_r4_i4.Tpo" -c -o pow_r4_i4.lo `test -f '$(srcdir)/generated/pow_r4_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_r4_i4.c; \
-@am__fastdepCC_TRUE@   then mv -f "$(DEPDIR)/pow_r4_i4.Tpo" "$(DEPDIR)/pow_r4_i4.Plo"; else rm -f "$(DEPDIR)/pow_r4_i4.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$(srcdir)/generated/pow_r4_i4.c' object='pow_r4_i4.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pow_r4_i4.lo `test -f '$(srcdir)/generated/pow_r4_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_r4_i4.c
-
-pow_r8_i4.lo: $(srcdir)/generated/pow_r8_i4.c
-@am__fastdepCC_TRUE@   if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pow_r8_i4.lo -MD -MP -MF "$(DEPDIR)/pow_r8_i4.Tpo" -c -o pow_r8_i4.lo `test -f '$(srcdir)/generated/pow_r8_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_r8_i4.c; \
-@am__fastdepCC_TRUE@   then mv -f "$(DEPDIR)/pow_r8_i4.Tpo" "$(DEPDIR)/pow_r8_i4.Plo"; else rm -f "$(DEPDIR)/pow_r8_i4.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$(srcdir)/generated/pow_r8_i4.c' object='pow_r8_i4.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pow_r8_i4.lo `test -f '$(srcdir)/generated/pow_r8_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_r8_i4.c
-
-pow_r10_i4.lo: $(srcdir)/generated/pow_r10_i4.c
-@am__fastdepCC_TRUE@   if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pow_r10_i4.lo -MD -MP -MF "$(DEPDIR)/pow_r10_i4.Tpo" -c -o pow_r10_i4.lo `test -f '$(srcdir)/generated/pow_r10_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_r10_i4.c; \
-@am__fastdepCC_TRUE@   then mv -f "$(DEPDIR)/pow_r10_i4.Tpo" "$(DEPDIR)/pow_r10_i4.Plo"; else rm -f "$(DEPDIR)/pow_r10_i4.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$(srcdir)/generated/pow_r10_i4.c' object='pow_r10_i4.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pow_r10_i4.lo `test -f '$(srcdir)/generated/pow_r10_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_r10_i4.c
-
-pow_r16_i4.lo: $(srcdir)/generated/pow_r16_i4.c
-@am__fastdepCC_TRUE@   if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pow_r16_i4.lo -MD -MP -MF "$(DEPDIR)/pow_r16_i4.Tpo" -c -o pow_r16_i4.lo `test -f '$(srcdir)/generated/pow_r16_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_r16_i4.c; \
-@am__fastdepCC_TRUE@   then mv -f "$(DEPDIR)/pow_r16_i4.Tpo" "$(DEPDIR)/pow_r16_i4.Plo"; else rm -f "$(DEPDIR)/pow_r16_i4.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$(srcdir)/generated/pow_r16_i4.c' object='pow_r16_i4.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pow_r16_i4.lo `test -f '$(srcdir)/generated/pow_r16_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_r16_i4.c
-
 pow_c4_i4.lo: $(srcdir)/generated/pow_c4_i4.c
 @am__fastdepCC_TRUE@   if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pow_c4_i4.lo -MD -MP -MF "$(DEPDIR)/pow_c4_i4.Tpo" -c -o pow_c4_i4.lo `test -f '$(srcdir)/generated/pow_c4_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/pow_c4_i4.c; \
 @am__fastdepCC_TRUE@   then mv -f "$(DEPDIR)/pow_c4_i4.Tpo" "$(DEPDIR)/pow_c4_i4.Plo"; else rm -f "$(DEPDIR)/pow_c4_i4.Tpo"; exit 1; fi
index e1357845ddcbebff9eb7e9ddd6e6efe75f9fd148..6aebef3cb82edfe41d986c1a5565edd980589188 100644 (file)
@@ -526,16 +526,12 @@ GFORTRAN_1.0 {
     _gfortran_pow_i8_i4;
     _gfortran_pow_i8_i8;
     _gfortran_pow_r10_i16;
-    _gfortran_pow_r10_i4;
     _gfortran_pow_r10_i8;
     _gfortran_pow_r16_i16;
-    _gfortran_pow_r16_i4;
     _gfortran_pow_r16_i8;
     _gfortran_pow_r4_i16;
-    _gfortran_pow_r4_i4;
     _gfortran_pow_r4_i8;
     _gfortran_pow_r8_i16;
-    _gfortran_pow_r8_i4;
     _gfortran_pow_r8_i8;
     _gfortran_product_c10;
     _gfortran_product_c16;