Patchwork patch to fix constant math - second small patch

login
register
mail settings
Submitter Kenneth Zadeck
Date Oct. 5, 2012, 10:48 p.m.
Message ID <506F63CC.40507@naturalbridge.com>
Download mbox | patch
Permalink /patch/189621/
State New
Headers show

Comments

Kenneth Zadeck - Oct. 5, 2012, 10:48 p.m.
This patch adds machinery to genmodes.c so that largest possible sizes 
of various data structures can be determined at gcc build time.  These 
functions create 3 symbols that are available in insn-modes.h:
MAX_BITSIZE_MODE_INT - the bitsize of the largest int.
MAX_BITSIZE_MODE_PARTIAL_INT - the bitsize of the largest partial int.
MAX_BITSIZE_MODE_ANY_INT - the largest bitsize of any kind of int.
2012-10-5  Kenneth Zadeck <zadeck@naturalbridge.com>

   	* genmodes.c (emit_max_int): New function.
	(emit_insn_modes_h): Added call to emit_max_function.
Kenneth Zadeck - Oct. 6, 2012, 3:55 p.m.
This is the third patch in the series of patches to fix constant math.
this one changes some predicates at the rtl level to use the new 
predicate CONST_SCALAR_INT_P.
I did not include a few that were tightly intertwined with other changes.

Not all of these changes are strictly mechanical.   Richard, when 
reviewing this had me make additional changes to remove what he thought 
were latent bugs at the rtl level.   However, it appears that the bugs 
were not latent.    I do not know what is going on here but i am smart 
enough to not look a gift horse in the mouth.

All of this was done on the same machine with no changes and identical 
configs.  It is an x86-64 with ubuntu 12-4.

ok for commit?

in the logs below, gbBaseline is a trunk from friday and the gbWide is 
the same revision but with my patches.  Some of this like 
gfortran.dg/pr32627 is obviously flutter, but the rest does not appear 
to be.

=========
heracles:~/gcc(13) gccBaseline/contrib/compare_tests 
gbBaseline/gcc/testsuite/gcc/gcc.log gbWide/gcc/testsuite/gcc/gcc.log
New tests that PASS:

gcc.dg/builtins-85.c scan-assembler mysnprintf
gcc.dg/builtins-85.c scan-assembler-not __chk_fail
gcc.dg/builtins-85.c (test for excess errors)


heracles:~/gcc(14) gccBaseline/contrib/compare_tests 
gbBaseline/gcc/testsuite/gfortran/gfortran.log 
gbWide/gcc/testsuite/gfortran/gfortran.log
New tests that PASS:

gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer -funroll-loops (test 
for excess errors)
gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer  (test for excess errors)
gfortran.dg/pr32627.f03  -Os  (test for excess errors)
gfortran.dg/pr32635.f  -O0  execution test
gfortran.dg/pr32635.f  -O0  (test for excess errors)
gfortran.dg/substr_6.f90  -O2  (test for excess errors)

Old tests that passed, that have disappeared: (Eeek!)

gfortran.dg/pr32627.f03  -O1  (test for excess errors)
gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer -funroll-all-loops 
-finline-functions  (test for excess errors)
gfortran.dg/pr32627.f03  -O3 -g  (test for excess errors)
gfortran.dg/substring_equivalence.f90  -O  (test for excess errors)
Using /home/zadeck/gcc/gccBaseline/gcc/testsuite/config/default.exp as 
tool-and-target-specific interface file.

         === g++ Summary ===

# of expected passes        49793
# of expected failures        284
# of unsupported tests        601

runtest completed at Fri Oct  5 16:10:20 2012
heracles:~/gcc(16) tail gbWide/gcc/testsuite/g++/g++.log Using 
/usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using /home/zadeck/gcc/gccWide/gcc/testsuite/config/default.exp as 
tool-and-target-specific interface file.

         === g++ Summary ===

# of expected passes        50472
# of expected failures        284
# of unsupported tests        613

runtest completed at Fri Oct  5 19:51:50 2012
Richard Guenther - Oct. 8, 2012, 9:06 a.m.
On Sat, Oct 6, 2012 at 12:48 AM, Kenneth Zadeck
<zadeck@naturalbridge.com> wrote:
> This patch adds machinery to genmodes.c so that largest possible sizes of
> various data structures can be determined at gcc build time.  These
> functions create 3 symbols that are available in insn-modes.h:
> MAX_BITSIZE_MODE_INT - the bitsize of the largest int.
> MAX_BITSIZE_MODE_PARTIAL_INT - the bitsize of the largest partial int.
> MAX_BITSIZE_MODE_ANY_INT - the largest bitsize of any kind of int.

Ok.  Please document these macros in rtl.texi.

Richard.
Richard Guenther - Oct. 8, 2012, 9:08 a.m.
On Sat, Oct 6, 2012 at 5:55 PM, Kenneth Zadeck <zadeck@naturalbridge.com> wrote:
> This is the third patch in the series of patches to fix constant math.
> this one changes some predicates at the rtl level to use the new predicate
> CONST_SCALAR_INT_P.
> I did not include a few that were tightly intertwined with other changes.
>
> Not all of these changes are strictly mechanical.   Richard, when reviewing
> this had me make additional changes to remove what he thought were latent
> bugs at the rtl level.   However, it appears that the bugs were not latent.
> I do not know what is going on here but i am smart enough to not look a gift
> horse in the mouth.
>
> All of this was done on the same machine with no changes and identical
> configs.  It is an x86-64 with ubuntu 12-4.
>
> ok for commit?

Patch missing, but if it's just mechanical changes and introduction
of CONST_SCALAR_INT_P consider it pre-approved.

Richard.

> in the logs below, gbBaseline is a trunk from friday and the gbWide is the
> same revision but with my patches.  Some of this like gfortran.dg/pr32627 is
> obviously flutter, but the rest does not appear to be.
>
> =========
> heracles:~/gcc(13) gccBaseline/contrib/compare_tests
> gbBaseline/gcc/testsuite/gcc/gcc.log gbWide/gcc/testsuite/gcc/gcc.log
> New tests that PASS:
>
> gcc.dg/builtins-85.c scan-assembler mysnprintf
> gcc.dg/builtins-85.c scan-assembler-not __chk_fail
> gcc.dg/builtins-85.c (test for excess errors)
>
>
> heracles:~/gcc(14) gccBaseline/contrib/compare_tests
> gbBaseline/gcc/testsuite/gfortran/gfortran.log
> gbWide/gcc/testsuite/gfortran/gfortran.log
> New tests that PASS:
>
> gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer -funroll-loops (test for
> excess errors)
> gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer  (test for excess errors)
> gfortran.dg/pr32627.f03  -Os  (test for excess errors)
> gfortran.dg/pr32635.f  -O0  execution test
> gfortran.dg/pr32635.f  -O0  (test for excess errors)
> gfortran.dg/substr_6.f90  -O2  (test for excess errors)
>
> Old tests that passed, that have disappeared: (Eeek!)
>
> gfortran.dg/pr32627.f03  -O1  (test for excess errors)
> gfortran.dg/pr32627.f03  -O3 -fomit-frame-pointer -funroll-all-loops
> -finline-functions  (test for excess errors)
> gfortran.dg/pr32627.f03  -O3 -g  (test for excess errors)
> gfortran.dg/substring_equivalence.f90  -O  (test for excess errors)
> Using /home/zadeck/gcc/gccBaseline/gcc/testsuite/config/default.exp as
> tool-and-target-specific interface file.
>
>         === g++ Summary ===
>
> # of expected passes        49793
> # of expected failures        284
> # of unsupported tests        601
>
> runtest completed at Fri Oct  5 16:10:20 2012
> heracles:~/gcc(16) tail gbWide/gcc/testsuite/g++/g++.log Using
> /usr/share/dejagnu/config/unix.exp as generic interface file for target.
> Using /home/zadeck/gcc/gccWide/gcc/testsuite/config/default.exp as
> tool-and-target-specific interface file.
>
>         === g++ Summary ===
>
> # of expected passes        50472
> # of expected failures        284
> # of unsupported tests        613
>
> runtest completed at Fri Oct  5 19:51:50 2012
>
>
>
>
>

Patch

Index: gcc/genmodes.c
===================================================================
--- gcc/genmodes.c	(revision 191978)
+++ gcc/genmodes.c	(working copy)
@@ -849,6 +849,38 @@  calc_wider_mode (void)
 
 #define print_closer() puts ("};")
 
+/* Compute the max bitsize of some of the classes of integers.  It may
+   be that there are needs for the other integer classes, and this
+   code is easy to extend.  */
+static void
+emit_max_int (void)
+{
+  unsigned int max, mmax;
+  struct mode_data *i;
+  int j;
+
+  puts ("");
+  for (max = 1, i = modes[MODE_INT]; i; i = i->next)
+    if (max < i->bytesize)
+	max = i->bytesize;
+  printf ("#define MAX_BITSIZE_MODE_INT %d*BITS_PER_UNIT\n", max);
+  mmax = max;
+  for (max = 1, i = modes[MODE_PARTIAL_INT]; i; i = i->next)
+    if (max < i->bytesize)
+	max = i->bytesize;
+  printf ("#define MAX_BITSIZE_MODE_PARTIAL_INT %d*BITS_PER_UNIT\n", max);
+  if (max > mmax)
+    mmax = max;
+  printf ("#define MAX_BITSIZE_MODE_ANY_INT %d*BITS_PER_UNIT\n", mmax);
+
+  mmax = 0;
+  for (j = 0; j < MAX_MODE_CLASS; j++)
+    for (i = modes[j]; i; i = i->next)
+      if (mmax < i->bytesize)
+	mmax = i->bytesize;
+  printf ("#define MAX_BITSIZE_MODE_ANY_MODE %d*BITS_PER_UNIT\n", mmax);
+}
+
 static void
 emit_insn_modes_h (void)
 {
@@ -913,6 +945,7 @@  enum machine_mode\n{");
 #endif
   printf ("#define CONST_MODE_IBIT%s\n", adj_ibit ? "" : " const");
   printf ("#define CONST_MODE_FBIT%s\n", adj_fbit ? "" : " const");
+  emit_max_int ();
   puts ("\
 \n\
 #endif /* insn-modes.h */");