https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87256

--- Comment #2 from Sergei Trofimovich <slyfox at inbox dot ru> ---
synth_mult() is called 57M times on this tiny sample.

I noticed there is a NUM_ALG_HASH_ENTRIES bucket size for already computed
algorithms for multiplication. The below tweak seems to workaround pathological
case:

--- a/gcc/expmed.h
+++ b/gcc/expmed.h
@@ -128,7 +128,7 @@ struct alg_hash_entry {

 /* The number of cache/hash entries.  */
 #if HOST_BITS_PER_WIDE_INT == 64
-#define NUM_ALG_HASH_ENTRIES 1031
+#define NUM_ALG_HASH_ENTRIES 10311
 #else
 #define NUM_ALG_HASH_ENTRIES 307
 #endif

$ ./xgcc -B. -O2 -fomit-frame-pointer -c -o bug.o bug.c -ftime-report

Time variable                                   usr           sys          wall
              GGC
 phase setup                        :   0.00 (  0%)   0.00 (  0%)   0.01 (  2%)
    960 kB ( 62%)
 phase parsing                      :   0.00 (  0%)   0.00 (  0%)   0.02 (  4%)
    109 kB (  7%)
 phase opt and generate             :   0.39 (100%)   0.00 (  0%)   0.46 ( 94%)
    464 kB ( 30%)
 preprocessing                      :   0.00 (  0%)   0.00 (  0%)   0.02 (  4%)
      9 kB (  1%)
 dominator optimization             :   0.00 (  0%)   0.00 (  0%)   0.02 (  4%)
      1 kB (  0%)
 expand                             :   0.37 ( 95%)   0.00 (  0%)   0.42 ( 86%)
     50 kB (  3%)
 combiner                           :   0.01 (  3%)   0.00 (  0%)   0.01 (  2%)
     97 kB (  6%)
 initialize rtl                     :   0.01 (  3%)   0.00 (  0%)   0.00 (  0%)
     13 kB (  1%)
 verify RTL sharing                 :   0.00 (  0%)   0.00 (  0%)   0.01 (  2%)
      0 kB (  0%)
 TOTAL                              :   0.39          0.00          0.49       
   1543 kB
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --enable-checking=release to disable checks.

Reply via email to