Bug 116166 - [13 Regression] risc-v (last) insn-emit-nn.c build takes hours
Summary: [13 Regression] risc-v (last) insn-emit-nn.c build takes hours
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 15.0
: P2 normal
Target Milestone: 13.4
Assignee: Richard Biener
URL:
Keywords: build, compile-time-hog
Depends on:
Blocks: 111600
  Show dependency treegraph
 
Reported: 2024-07-31 21:52 UTC by Mark Wielaard
Modified: 2025-01-06 18:27 UTC (History)
8 users (show)

See Also:
Host:
Target: riscv
Build:
Known to work: 14.2.1, 15.0
Known to fail: 14.2.0
Last reconfirmed: 2024-08-02 00:00:00


Attachments
preprocessed insn-emit-96.cc (692.43 KB, application/gzip)
2024-07-31 21:52 UTC, Mark Wielaard
Details
add a param to limit BBs for dominator pass (867 bytes, patch)
2024-08-05 19:29 UTC, Andi Kleen
Details | Diff
reduced testcase (15.87 KB, text/plain)
2024-08-06 10:42 UTC, Richard Biener
Details
limit forward thread search space (737 bytes, patch)
2024-08-06 12:52 UTC, Richard Biener
Details | Diff
patch I am testing (1.90 KB, patch)
2024-08-06 13:10 UTC, Richard Biener
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2024-07-31 21:52:25 UTC
Created attachment 58789 [details]
preprocessed insn-emit-96.cc

Compiling on risc-v the (last) insn-emit-nn.s takes hours. Even using --with-insnemit-partitions=96 insn-emit-96.cc is still 2.5MB.

preprocessed source attached.

git gcc-15-2456-g69a9ee05c68

/home/builder/worker/gcc-full-fedora-riscv/gcc-build/./prev-gcc/cc1plus -quiet -march=rv64imafdc_zicsr_zifencei_zaamo_zalrsc -mabi=lp64d -misa-spec=20191213 -mtls-dialect=trad -march=rv64imafdc_zicsr_zifencei_zca_zcd -g -gtoggle -O2 -Wwrite-strings /tmp/insn-emit-96.i -fno-checking -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -fno-PIE -o /tmp/insn-emit-96.s

perf -g profile looks like:

+   98.46%     0.00%  cc1plus  cc1plus           [.] jump_threader::thread_around_empty_blocks
+   98.42%     0.00%  cc1plus  cc1plus           [.] jump_threader::simplify_control_stmt_condition
+   98.41%     0.00%  cc1plus  cc1plus           [.] jump_threader::simplify_control_stmt_condition_1
+   98.33%     0.00%  cc1plus  cc1plus           [.] dom_jt_simplifier::simplify
+   98.26%     0.00%  cc1plus  cc1plus           [.] hybrid_jt_simplifier::simplify
+   97.84%     0.00%  cc1plus  cc1plus           [.] path_range_query::reset_path
+   96.53%     0.07%  cc1plus  cc1plus           [.] path_range_query::compute_ranges
+   95.45%     0.44%  cc1plus  cc1plus           [.] path_range_query::compute_ranges_in_block
+   46.65%     0.19%  cc1plus  cc1plus           [.] gori_compute::edge_range_p
+   40.20%     0.11%  cc1plus  cc1plus           [.] gori_compute::compute_operand_range
+   38.54%     0.33%  cc1plus  cc1plus           [.] gori_compute::compute_operand1_range
+   25.39%     0.72%  cc1plus  cc1plus           [.] irange::intersect
+   20.40%     0.16%  cc1plus  cc1plus           [.] path_range_query::compute_outgoing_relations
+   14.79%     8.26%  cc1plus  cc1plus           [.] generic_wide_int<wide_int_storage>::~generic_wide_int
+   14.39%     0.27%  cc1plus  cc1plus           [.] fur_source::register_outgoing_edges
+   14.21%     0.23%  cc1plus  cc1plus           [.] gcond_edge_range
+   13.01%     7.29%  cc1plus  cc1plus           [.] generic_wide_int<wide_int_storage>::generic_wide_int
+   12.35%     1.15%  cc1plus  cc1plus           [.] int_range<3u, true>::~int_range
+   11.95%     0.26%  cc1plus  cc1plus           [.] value_range::~value_range
+   10.89%     0.89%  cc1plus  cc1plus           [.] irange::maybe_resize
+   10.22%     0.18%  cc1plus  cc1plus           [.] path_range_query::get_cache
+   10.19%     0.45%  cc1plus  cc1plus           [.] irange::set

Will run overnight with -ftime-report to get better stats.
Comment 1 Drea Pinski 2024-07-31 22:06:04 UTC
Looks ranger related.
Comment 2 Mark Wielaard 2024-08-01 07:11:05 UTC
Time variable                                   usr           sys          wall           GGC
 phase setup                        :   0.10 (  0%)   0.00 (  0%)   0.11 (  0%)  2844k (  0%)
 phase parsing                      :  37.04 (  0%)  12.65 ( 32%)  49.85 (  0%)   306M ( 46%)
 phase lang. deferred               :   0.44 (  0%)   0.08 (  0%)   0.52 (  0%)  2970k (  0%)
 phase opt and generate             :21747.57 (100%)  27.03 ( 68%)21848.93 (100%)   348M ( 53%)
 phase last asm                     :   0.07 (  0%)   0.01 (  0%)   0.08 (  0%)    69k (  0%)
 |name lookup                       :   5.85 (  0%)   1.62 (  4%)   7.20 (  0%)  4335k (  1%)
 |overload resolution               :   5.41 (  0%)   1.51 (  4%)   6.97 (  0%)    30M (  5%)
 garbage collection                 :   1.50 (  0%)   2.15 (  5%)   3.67 (  0%)     0  (  0%)
 dump files                         :   0.86 (  0%)   0.07 (  0%)   1.00 (  0%)     0  (  0%)
 callgraph construction             :   1.28 (  0%)   0.09 (  0%)   1.27 (  0%)  4404k (  1%)
 callgraph optimization             :   1.03 (  0%)   0.11 (  0%)   1.10 (  0%)   108k (  0%)
 callgraph functions expansion      :21669.92 ( 99%)  25.01 ( 63%)21768.97 ( 99%)   266M ( 40%)
 callgraph ipa passes               :  72.78 (  0%)   1.83 (  5%)  74.87 (  0%)    29M (  4%)
 ipa function summary               :   1.87 (  0%)   0.09 (  0%)   1.96 (  0%)  1513k (  0%)
 ipa dead code removal              :   0.04 (  0%)   0.00 (  0%)   0.04 (  0%)     0  (  0%)
 ipa cp                             :   0.55 (  0%)   0.00 (  0%)   0.61 (  0%)   695k (  0%)
 ipa inlining heuristics            :   0.19 (  0%)   0.14 (  0%)   0.40 (  0%)   345k (  0%)
 ipa function splitting             :   0.62 (  0%)   0.01 (  0%)   0.66 (  0%)    52k (  0%)
 ipa various optimizations          :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 ipa reference                      :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 ipa pure const                     :   0.61 (  0%)   0.02 (  0%)   0.46 (  0%)     0  (  0%)
 ipa icf                            :   0.47 (  0%)   0.00 (  0%)   0.47 (  0%)     0  (  0%)
 ipa SRA                            :   2.09 (  0%)   0.02 (  0%)   2.11 (  0%)   137k (  0%)
 ipa free lang data                 :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 ipa free inline summary            :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 ipa modref                         :   0.67 (  0%)   0.00 (  0%)   0.67 (  0%)   541k (  0%)
 cfg construction                   :   0.84 (  0%)   0.10 (  0%)   0.88 (  0%)    10M (  2%)
 cfg cleanup                        :   6.88 (  0%)   0.07 (  0%)   6.99 (  0%)  2264k (  0%)
 trivially dead code                :   0.80 (  0%)   0.02 (  0%)   0.78 (  0%)     0  (  0%)
 df scan insns                      :   1.27 (  0%)   0.05 (  0%)   1.32 (  0%)    88k (  0%)
 df reaching defs                   :   1.58 (  0%)   0.07 (  0%)   1.52 (  0%)     0  (  0%)
 df live regs                       :   6.56 (  0%)   0.17 (  0%)   7.13 (  0%)     0  (  0%)
 df live&initialized regs           :   4.12 (  0%)   0.05 (  0%)   4.18 (  0%)     0  (  0%)
 df must-initialized regs           :   0.19 (  0%)   0.01 (  0%)   0.35 (  0%)     0  (  0%)
 df use-def / def-use chains        :   0.67 (  0%)   0.01 (  0%)   0.65 (  0%)     0  (  0%)
 df reg dead/unused notes           :   2.92 (  0%)   0.08 (  0%)   3.31 (  0%)  2712k (  0%)
 register information               :   4.01 (  0%)   0.19 (  0%)   4.33 (  0%)     0  (  0%)
 alias analysis                     :   3.40 (  0%)   0.12 (  0%)   3.33 (  0%)    10M (  2%)
 alias stmt walking                 :   0.47 (  0%)   0.05 (  0%)   0.55 (  0%)     0  (  0%)
 register scan                      :   0.21 (  0%)   0.02 (  0%)   0.23 (  0%)    59k (  0%)
 rebuild jump labels                :   0.41 (  0%)   0.00 (  0%)   0.44 (  0%)     0  (  0%)
 preprocessing                      :   2.51 (  0%)   2.79 (  7%)   5.46 (  0%)    26M (  4%)
 parser (global)                    :  12.93 (  0%)   4.93 ( 12%)  17.89 (  0%)   175M ( 27%)
 parser struct body                 :   1.31 (  0%)   0.24 (  1%)   1.52 (  0%)  6856k (  1%)
 parser enumerator list             :   0.76 (  0%)   0.25 (  1%)   0.90 (  0%)  8060k (  1%)
 parser function body               :  13.71 (  0%)   3.11 (  8%)  16.57 (  0%)    61M (  9%)
 parser inl. func. body             :   2.42 (  0%)   0.62 (  2%)   3.00 (  0%)    12M (  2%)
 parser inl. meth. body             :   0.54 (  0%)   0.06 (  0%)   0.60 (  0%)  3821k (  1%)
 template instantiation             :   2.45 (  0%)   0.61 (  2%)   3.29 (  0%)    16M (  2%)
 constant expression evaluation     :   0.77 (  0%)   0.10 (  0%)   1.03 (  0%)   192k (  0%)
 early inlining heuristics          :   0.16 (  0%)   0.01 (  0%)   0.27 (  0%)   950k (  0%)
 inline parameters                  :   4.17 (  0%)   0.10 (  0%)   4.24 (  0%)  2386k (  0%)
 integration                        :   0.70 (  0%)   0.16 (  0%)   0.91 (  0%)  4810k (  1%)
 tree gimplify                      :   1.79 (  0%)   0.10 (  0%)   1.96 (  0%)    28M (  4%)
 tree eh                            :   0.15 (  0%)   0.00 (  0%)   0.14 (  0%)    26k (  0%)
 tree CFG construction              :   1.13 (  0%)   0.01 (  0%)   1.22 (  0%)    20M (  3%)
 tree CFG cleanup                   :  14.75 (  0%)   0.39 (  1%)  14.79 (  0%)   457k (  0%)
 tree tail merge                    :   1.19 (  0%)   0.04 (  0%)   1.11 (  0%)  4396k (  1%)
 tree VRP                           :  29.91 (  0%)   0.30 (  1%)  29.96 (  0%)  1976k (  0%)
 tree Early VRP                     :  29.62 (  0%)   0.24 (  1%)  30.21 (  0%)  1108k (  0%)
 tree copy propagation              :   1.41 (  0%)   0.04 (  0%)   1.30 (  0%)     0  (  0%)
 tree PTA                           :   3.10 (  0%)   0.32 (  1%)   3.67 (  0%)   906k (  0%)
 tree SSA other                     :   0.01 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 tree SSA rewrite                   :   0.75 (  0%)   0.13 (  0%)   0.91 (  0%)  4584k (  1%)
 tree SSA incremental               :   0.43 (  0%)   0.01 (  0%)   0.29 (  0%)   222k (  0%)
 tree operand scan                  :   1.40 (  0%)   0.14 (  0%)   1.40 (  0%)    10M (  2%)
 dominator optimization             :21131.67 ( 97%)  13.94 ( 35%)21217.63 ( 97%)    17M (  3%)
 backwards jump threading           : 265.28 (  1%)   1.52 (  4%) 267.81 (  1%)    39M (  6%)
 tree SRA                           :   0.00 (  0%)   0.02 (  0%)   0.04 (  0%)     0  (  0%)
 isolate eroneous paths             :   0.19 (  0%)   0.00 (  0%)   0.17 (  0%)     0  (  0%)
 tree CCP                           :   9.22 (  0%)   0.28 (  1%)   9.79 (  0%)   930k (  0%)
 tree split crit edges              :   0.21 (  0%)   0.04 (  0%)   0.26 (  0%)  4423k (  1%)
 tree reassociation                 :   0.46 (  0%)   0.01 (  0%)   0.44 (  0%)    27k (  0%)
 tree PRE                           :   4.10 (  0%)   0.20 (  1%)   4.41 (  0%)  9833k (  1%)
 tree FRE                           :   9.94 (  0%)   0.23 (  1%)  10.24 (  0%)  1125k (  0%)
 tree code sinking                  :   0.85 (  0%)   0.05 (  0%)   1.00 (  0%)  8747k (  1%)
 tree linearize phis                :   0.43 (  0%)   0.04 (  0%)   0.64 (  0%)  1158k (  0%)
 tree backward propagate            :   0.10 (  0%)   0.02 (  0%)   0.10 (  0%)     0  (  0%)
 tree forward propagate             :   3.19 (  0%)   0.11 (  0%)   3.17 (  0%)   171k (  0%)
 tree phiprop                       :   0.12 (  0%)   0.00 (  0%)   0.08 (  0%)     0  (  0%)
 tree conservative DCE              :   0.65 (  0%)   0.03 (  0%)   0.75 (  0%)     0  (  0%)
 tree aggressive DCE                :   0.87 (  0%)   0.05 (  0%)   0.82 (  0%)  2103k (  0%)
 tree buildin call DCE              :   0.04 (  0%)   0.00 (  0%)   0.08 (  0%)     0  (  0%)
 tree DSE                           :   0.95 (  0%)   0.06 (  0%)   0.91 (  0%)  8272  (  0%)
 PHI merge                          :   0.03 (  0%)   0.01 (  0%)   0.03 (  0%)     0  (  0%)
 tree loop optimization             :   0.02 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 tree loop invariant motion         :   0.03 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 complete unrolling                 :   0.02 (  0%)   0.00 (  0%)   0.03 (  0%)     0  (  0%)
 tree slp vectorization             :   1.33 (  0%)   0.09 (  0%)   1.58 (  0%)  3311k (  0%)
 tree copy headers                  :   0.02 (  0%)   0.00 (  0%)   0.02 (  0%)   984k (  0%)
 tree SSA uncprop                   :   0.44 (  0%)   0.01 (  0%)   0.59 (  0%)     0  (  0%)
 tree NRV optimization              :   0.01 (  0%)   0.00 (  0%)   0.03 (  0%)    42k (  0%)
 tree switch conversion             :   0.36 (  0%)   0.02 (  0%)   0.35 (  0%)   554k (  0%)
 tree switch lowering               :   0.20 (  0%)   0.02 (  0%)   0.23 (  0%)    99k (  0%)
 gimple CSE sin/cos                 :   0.00 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 gimple expand pow                  :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 gimple widening/fma detection      :   0.08 (  0%)   0.00 (  0%)   0.13 (  0%)    43k (  0%)
 tree strlen optimization           :   0.30 (  0%)   0.00 (  0%)   0.29 (  0%)   984k (  0%)
 tree modref                        :   1.37 (  0%)   0.11 (  0%)   1.54 (  0%)  1012k (  0%)
 dominance frontiers                :   0.20 (  0%)   0.00 (  0%)   0.19 (  0%)     0  (  0%)
 dominance computation              :   7.09 (  0%)   0.14 (  0%)   7.04 (  0%)     0  (  0%)
 control dependences                :   0.19 (  0%)   0.01 (  0%)   0.12 (  0%)     0  (  0%)
 out of ssa                         :   0.45 (  0%)   0.01 (  0%)   0.41 (  0%)   357k (  0%)
 expand vars                        :   0.07 (  0%)   0.00 (  0%)   0.04 (  0%)   225k (  0%)
 expand                             :   3.47 (  0%)   0.62 (  2%)   4.11 (  0%)    31M (  5%)
 post expand cleanups               :   1.91 (  0%)   0.18 (  0%)   2.20 (  0%)  9495k (  1%)
 varconst                           :   0.07 (  0%)   0.02 (  0%)   0.10 (  0%)  4864  (  0%)
 lower subreg                       :   0.01 (  0%)   0.00 (  0%)   0.03 (  0%)     0  (  0%)
 jump                               :   0.03 (  0%)   0.00 (  0%)   0.04 (  0%)     0  (  0%)
 forward prop                       :   4.45 (  0%)   0.16 (  0%)   4.74 (  0%)    71k (  0%)
 CSE                                :   9.81 (  0%)   0.17 (  0%)   9.61 (  0%)   187k (  0%)
 dead code elimination              :   0.87 (  0%)   0.01 (  0%)   0.98 (  0%)     0  (  0%)
 dead store elim1                   :   0.97 (  0%)   0.05 (  0%)   0.81 (  0%)   490k (  0%)
 dead store elim2                   :   1.43 (  0%)   0.09 (  0%)   1.50 (  0%)  1519k (  0%)
 loop analysis                      :   0.02 (  0%)   0.00 (  0%)   0.04 (  0%)     0  (  0%)
 loop init                          :   4.28 (  0%)   0.12 (  0%)   4.67 (  0%)  3446k (  1%)
 loop invariant motion              :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 loop fini                          :   0.21 (  0%)   0.03 (  0%)   0.21 (  0%)     0  (  0%)
 CPROP                              :  11.92 (  0%)   0.25 (  1%)  12.44 (  0%)    10M (  2%)
 PRE                                :   0.55 (  0%)   0.03 (  0%)   0.63 (  0%)   132k (  0%)
 auto inc dec                       :   0.17 (  0%)   0.00 (  0%)   0.20 (  0%)    22k (  0%)
 CSE 2                              :   6.98 (  0%)   0.07 (  0%)   7.12 (  0%)    69k (  0%)
 branch prediction                  :   1.67 (  0%)   0.02 (  0%)   1.85 (  0%)   127k (  0%)
 combiner                           :   3.49 (  0%)   0.10 (  0%)   3.49 (  0%)  2481k (  0%)
 if-conversion                      :   1.91 (  0%)   0.14 (  0%)   2.00 (  0%)  5446k (  1%)
 mode switching                     :   0.00 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 scheduling                         :  51.15 (  0%)   0.38 (  1%)  51.57 (  0%)  2454k (  0%)
 early rematerialization            :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 integrated RA                      :  11.40 (  0%)   0.22 (  1%)  11.53 (  0%)    40M (  6%)
 LRA non-specific                   :   2.69 (  0%)   0.01 (  0%)   2.88 (  0%)   430k (  0%)
 LRA virtuals elimination           :   3.26 (  0%)   0.05 (  0%)   3.42 (  0%)   283k (  0%)
 LRA reload inheritance             :   0.55 (  0%)   0.02 (  0%)   0.55 (  0%)   176k (  0%)
 LRA create live ranges             :   1.03 (  0%)   0.03 (  0%)   0.99 (  0%)   105k (  0%)
 LRA hard reg assignment            :   0.21 (  0%)   0.00 (  0%)   0.21 (  0%)     0  (  0%)
 LRA rematerialization              :   0.19 (  0%)   0.00 (  0%)   0.17 (  0%)     0  (  0%)
 reload                             :   0.07 (  0%)   0.00 (  0%)   0.08 (  0%)    38k (  0%)
 reload CSE regs                    :   4.85 (  0%)   0.09 (  0%)   4.74 (  0%)  1999k (  0%)
 ree                                :   0.39 (  0%)   0.00 (  0%)   0.43 (  0%)  1880  (  0%)
 thread pro- & epilogue             :   2.52 (  0%)   0.06 (  0%)   2.73 (  0%)  2690k (  0%)
 if-conversion 2                    :   0.25 (  0%)   0.02 (  0%)   0.31 (  0%)  1560  (  0%)
 peephole 2                         :   0.39 (  0%)   0.00 (  0%)   0.48 (  0%)     0  (  0%)
 hard reg cprop                     :   1.24 (  0%)   0.15 (  0%)   1.39 (  0%)  5568  (  0%)
 scheduling 2                       :   8.23 (  0%)   0.15 (  0%)   8.22 (  0%)   481k (  0%)
 machine dep reorg                  :   0.02 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 reorder blocks                     :   1.61 (  0%)   0.08 (  0%)   1.66 (  0%)  4501k (  1%)
 shorten branches                   :   0.63 (  0%)   0.02 (  0%)   0.66 (  0%)     0  (  0%)
 final                              :   1.97 (  0%)   0.31 (  1%)   2.23 (  0%)  4359k (  1%)
 symout                             :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 tree if-combine                    :   0.28 (  0%)   0.00 (  0%)   0.23 (  0%)  2800  (  0%)
 if to switch conversion            :   0.51 (  0%)   0.01 (  0%)   0.64 (  0%)  1649k (  0%)
 straight-line strength reduction   :   0.36 (  0%)   0.02 (  0%)   0.28 (  0%)    54k (  0%)
 store merging                      :   0.11 (  0%)   0.02 (  0%)   0.13 (  0%)    17k (  0%)
 initialize rtl                     :   0.15 (  0%)   0.01 (  0%)   0.16 (  0%)    18k (  0%)
 address lowering                   :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 access analysis                    :   1.14 (  0%)   0.08 (  0%)   1.27 (  0%)   168  (  0%)
 unaccounted optimizations          :   0.02 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 rest of compilation                :  19.58 (  0%)   0.50 (  1%)  20.01 (  0%)    17M (  3%)
 unaccounted post reload            :   0.00 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 remove unused locals               :   0.55 (  0%)   0.02 (  0%)   0.69 (  0%)     0  (  0%)
 address taken                      :   0.51 (  0%)   0.02 (  0%)   0.49 (  0%)     0  (  0%)
 rebuild frequencies                :   0.07 (  0%)   0.00 (  0%)   0.09 (  0%)     0  (  0%)
 repair loop structures             :   0.15 (  0%)   0.00 (  0%)   0.10 (  0%)     0  (  0%)
 TOTAL                              :21785.22         39.77      21899.49          660M
Comment 3 Richard Biener 2024-08-01 07:39:45 UTC
There's another PR where DOM shows up via ranger also at -O1 - does -O1 help here?

In that PR I presented a prototype of limiting the dominator walk of ranger
which looks unbound (but I expected Ranger folks to pick that idea up).
See PR114855 comment#13.

Note DOM is the only user left of the forward jump threading.
Comment 4 Mark Wielaard 2024-08-01 20:19:35 UTC
(In reply to Richard Biener from comment #3)
> There's another PR where DOM shows up via ranger also at -O1 - does -O1 help
> here?

No. With -O2 it took 6 hours for that file to compile. With -O1 it is still running after 12 hours...
Comment 5 Andi Kleen 2024-08-01 21:44:51 UTC
Have you tried a LTO build? It can split large files.

It's not incremental however (unless the recent patches for that go in)
Comment 6 Drea Pinski 2024-08-01 21:46:19 UTC
(In reply to Andi Kleen from comment #5)
> Have you tried a LTO build? It can split large files.
> 
> It's not incremental however (unless the recent patches for that go in)

I don't think it matters in this case since this is one large function which is causing the jump threading going wrong.
Comment 7 Andrew Macleod 2024-08-02 00:41:04 UTC
I think fixing 114855 will probably resolve this one too. Its a more "managable" test case.   I'm trying to have a look, but I am off next week so it isn't imminent.

Meanwhile the "workaround" might be to use '-fno-tree-dominator-opts'  and maybe '-fno-thread-jumps -fno-tree-reassoc'.

I don't know if the no-tree-reassoc is still necessary, but when I was looking at 114855 for VRP it died in reassociation if I turned off thread-jumps.
Comment 8 Sam James 2024-08-02 01:16:52 UTC
Confirming as I've had reports of this & we have PR111600.
Comment 9 Sam James 2024-08-02 22:02:20 UTC Comment hidden (obsolete)
Comment 10 Mark Wielaard 2024-08-04 18:30:48 UTC
(In reply to Andrew Macleod from comment #7)
> Meanwhile the "workaround" might be to use '-fno-tree-dominator-opts'

That reduces the compile time from hours to just 15 minutes!

Still trying to figure out where to insert it. Adding it to BOOT_CFLAGS seems overkill and creates warning/errors for various string-compare and format-truncation warnings because it is missing some constant optimizations.
Comment 11 Andreas Schwab 2024-08-04 18:46:51 UTC
You can add target-specific flags like this:

$(INSNEMIT_SEQ_O): ALL_COMPILERFLAGS += -fno-tree-dominator-opts
Comment 12 Mark Wielaard 2024-08-05 16:32:03 UTC
(In reply to Andreas Schwab from comment #11)
> You can add target-specific flags like this:
> 
> $(INSNEMIT_SEQ_O): ALL_COMPILERFLAGS += -fno-tree-dominator-opts

Thanks. With "$(GIMPLE_MATCH_PD_SEQ_O) $(INSNEMIT_SEQ_O) insn-opinit.o insn-recog.o: ALL_COMPILERFLAGS += -O1 -fno-tree-dominator-opts" a make -j64 drops from 8 hours to 3.5 hours:

real	202m25.031s
user	2209m7.176s
sys	108m49.102s

Now insn-recog.cc (even though it is included in the workaround) takes the longest time (~1 hour) to compile.
Comment 13 Andi Kleen 2024-08-05 19:29:52 UTC
Created attachment 58842 [details]
add a param to limit BBs for dominator pass

Maybe something like this patch. It adds a check to disable the dom passes when the number of BBs per function exceeds a threshold. By default it is disabled, but you can set it with --param dom-bb-limit=10000 or similar
Comment 14 Richard Biener 2024-08-06 08:06:54 UTC
(In reply to Andi Kleen from comment #13)
> Created attachment 58842 [details]
> add a param to limit BBs for dominator pass
> 
> Maybe something like this patch. It adds a check to disable the dom passes
> when the number of BBs per function exceeds a threshold. By default it is
> disabled, but you can set it with --param dom-bb-limit=10000 or similar

The dominator pass isn't the problem - it's ranger used by the jump threading
from it.  See the patch in the other PR - you can try if that helps.
Comment 15 Richard Biener 2024-08-06 09:10:13 UTC
(In reply to Mark Wielaard from comment #12)
> (In reply to Andreas Schwab from comment #11)
> > You can add target-specific flags like this:
> > 
> > $(INSNEMIT_SEQ_O): ALL_COMPILERFLAGS += -fno-tree-dominator-opts
> 
> Thanks. With "$(GIMPLE_MATCH_PD_SEQ_O) $(INSNEMIT_SEQ_O) insn-opinit.o
> insn-recog.o: ALL_COMPILERFLAGS += -O1 -fno-tree-dominator-opts" a make -j64
> drops from 8 hours to 3.5 hours:
> 
> real	202m25.031s
> user	2209m7.176s
> sys	108m49.102s
> 
> Now insn-recog.cc (even though it is included in the workaround) takes the
> longest time (~1 hour) to compile.

Compiling insn-recog.cc for a cross-compiler to riscv on x86_64 with trunk
and -O2 takes 90s with a quite flat profile.

Are those worst timings using a stage1 compiler built with default flags (-O0)?

Seeing the profile in the description I'll note the backwards threader has
a search depth for jump thread paths (--param max-jump-thread-paths) but
thread_around_empty_blocks search space is unlimited - with EDGE_NO_COPY_SRC_BLOCK we do not account any stmts towards the stmt limit.

We're also doing a lot of redundant stmt simplifications by likely quadratically
exploring jump threading paths.  And each hybrid_jt_simplifier::simplify
call resets the path query path which we know is a very expensive operation,
it also shares the issues the backwards threader originally had, starting
with too big imports.  Doing that up to 2^four times for each block is
wasteful - simplify_control_stmt_condition_1 ends up calling
hybrid_jt_simplifier::simplify through dom_jt_simplifier::simplify and
while simplify_control_stmt_condition_1 has a recursion limit while
processing & and | it recurses to both arms, something ranger can do
itself(?).

The threader JT simplifier is over-abstracted - only DOM seems to use
hybrid_jt_simplifier.  The following should cut compile-time down
significantly (I'm not sure if the "old" DOM equiv lookup done by
dom-simplify is even necessary).  IMO "gimping" the old forward threader
with ranger was misguided as it was supposed to vanish anyway.

diff --git a/gcc/tree-ssa-threadedge.cc b/gcc/tree-ssa-threadedge.cc
index 7f82639b8ec..cac290175d4 100644
--- a/gcc/tree-ssa-threadedge.cc
+++ b/gcc/tree-ssa-threadedge.cc
@@ -634,7 +634,8 @@ jump_threader::simplify_control_stmt_condition_1
      then use the pass specific callback to simplify the condition.  */
   if (!res
       || !is_gimple_min_invariant (res))
-    res = m_simplifier->simplify (dummy_cond, stmt, e->src, m_state);
+    res = m_simplifier->simplify (dummy_cond, stmt, e->src,
+                                 limit == 4 ? m_state : NULL);
 
   return res;
 }

Note it doesn't help we're trying normal/empty thread stuff over and over.
Possibly RISC-V has "bad" LOGICAL_OP_NON_SHORT_CIRCUIT, it defines it to zero
which means all && and || conditions are CFG branches initially.

Can someone try adding --param logical-op-non-short-circuit=1 to that
FLAGS workaround?
Comment 16 Richard Biener 2024-08-06 09:16:09 UTC
So with --param logical-op-non-short-circuit=1 (and my patch) the insn-emit-96.cc testcase as attached compiles in 100s and

 dominator optimization             :   5.62 (  6%)   0.05 (  1%)   5.56 (  5%)  3015k (  0%)
 backwards jump threading           :  27.60 ( 27%)   0.02 (  0%)  27.63 ( 26%)  6783k (  1%)

The reproducing run with unpatched tree still runs since 27 minutes,
the patched tree still runs since 12 minutes.
Comment 17 Richard Biener 2024-08-06 10:31:03 UTC
(In reply to Richard Biener from comment #16)
> So with --param logical-op-non-short-circuit=1 (and my patch) the
> insn-emit-96.cc testcase as attached compiles in 100s and
> 
>  dominator optimization             :   5.62 (  6%)   0.05 (  1%)   5.56 ( 
> 5%)  3015k (  0%)
>  backwards jump threading           :  27.60 ( 27%)   0.02 (  0%)  27.63 (
> 26%)  6783k (  1%)
> 
> The reproducing run with unpatched tree still runs since 27 minutes,
> the patched tree still runs since 12 minutes.

My unpatched reproducing run finished in 2623s:

 dominator optimization             :2537.62 ( 97%)   0.16 (  4%)2538.50 ( 97%)    17M (  3%)
 backwards jump threading           :  34.21 (  1%)   0.13 (  3%)  34.39 (  1%)    39M (  6%)

and the patched finished in 2599s, not much of an improvement:

 dominator optimization             :2514.61 ( 97%)   0.13 (  3%)2515.28 ( 97%)    17M (  3%)
 backwards jump threading           :  33.05 (  1%)   0.08 (  2%)  33.18 (  1%)    39M (  6%)


Note the testcase can be reduced to maybe_code_for_pred_indexed_load which
takes 10 minutes to compile.
Comment 18 Richard Biener 2024-08-06 10:42:59 UTC
Created attachment 58847 [details]
reduced testcase

Reduced testcase that reproduces the issue on x86_64 with --param logical-op-non-short-circuit=0

A release checking GCC 13 takes 38s and shows

 dominator optimization             :  37.47 ( 98%)   0.01 (  9%)  37.50 ( 98%)  1959k (  6%)

GCC 14 is worse:

 dominator optimization             :  76.10 ( 99%)   0.01 (  8%)  76.13 ( 99%)  1958k (  6%)

GCC 15 (with checking):

 dominator optimization             : 126.05 ( 99%)   0.04 ( 31%) 126.08 ( 98%)  1958k (  6%)
Comment 19 Richard Biener 2024-08-06 12:01:46 UTC
Note GCC 12 builds the testcase in 1s so this is a regression from the ranger enablement in DOM (not to mention the overall slowness increase over the past revs).
Comment 20 Richard Biener 2024-08-06 12:50:14 UTC
So interestingly this is a case where we run into the irange::maybe_resize
re-allocation a lot (48 Million times), so a callgrind profile has
that and the corresponding DTOR at top in the 'Self' reporting order.

From the path_range_query::compute_ranges -> compute_ranges_in_block counts
we can infer the average path length is 178(!) and mostly composed of
"empty" blocks (but we've guessed that already).  That's all from just 550
thread_across_edge calls where we are able to find a normal thread and
then a very deep empty tail where we can simplify all conditions.

That's where the quadraticness comes in - as we enlarge the path for each
condition we simplify (and add a block) we re-compute ranges for all blocks
collected sofar.  I've noticed with the backwards threader that path
ranger isn't very good in the ability to preserve a cache when adding
blocks.  But in the case of forward threading resetting the cache shouldn't
be necessary - we might get additional "interesting" names to analyze but
already analyzed names do not need re-analyzing (as opposed to the backward
threader where we add blocks at the start of the path and thus would
possibly get refined ranges).  We only need to clear the cache when
popping blocks - and even then only for names defined in the popped block.

A more pragmatic fix would be to limit the number of EDGE_NO_COPY_SRC_BLOCK
blocks we add to the path aka the depth of the thread_around_empty_blocks
recursion.  Limiting that to 10 for example makes the testcase compile in 1s.
Implementing search space limiting and re-using --param max-jump-thread-paths
works as well, resulting in 3s.
Comment 21 Richard Biener 2024-08-06 12:52:12 UTC
Created attachment 58848 [details]
limit forward thread search space

Hackish patch (shouldn't use a global var) to apply a search space limit
for the forward threader.  For the backward threader this limits the number
of edges we walk when exploring paths leading to the path exit jump.  This
patch limits the number of edges we walk when exploring paths from the
path entry edge.
Comment 22 Richard Biener 2024-08-06 13:10:34 UTC
Created attachment 58849 [details]
patch I am testing

I am testing this.  It doesn't help PR114855 which runs into a different quadraticness.
Comment 23 Andrew Macleod 2024-08-06 17:19:26 UTC
(In reply to Richard Biener from comment #20)


> collected sofar.  I've noticed with the backwards threader that path
> ranger isn't very good in the ability to preserve a cache when adding
> blocks.  But in the case of forward threading resetting the cache shouldn't

I know only a little about the path ranger. I believe it is primarily a path finding class which uses ranger to provide ranges on entry ot the path, and then goes and walks the various path combinations utilizing GORI to calculate any outgoing ranges of ssa-names it thinks are interesting to determine if any conditions can folded on some path(s).


> be necessary - we might get additional "interesting" names to analyze but
> already analyzed names do not need re-analyzing (as opposed to the backward
> threader where we add blocks at the start of the path and thus would
> possibly get refined ranges).  We only need to clear the cache when
> popping blocks - and even then only for names defined in the popped block.
> 
> A more pragmatic fix would be to limit the number of EDGE_NO_COPY_SRC_BLOCK
> blocks we add to the path aka the depth of the thread_around_empty_blocks
> recursion.  Limiting that to 10 for example makes the testcase compile in 1s.
> Implementing search space limiting and re-using --param max-jump-thread-paths
> works as well, resulting in 3s.

If there are no limits on its depth, well that could be a problem :-)  Aldy Understands this much better, we should engage him upon his return.
Comment 24 GCC Commits 2024-08-07 07:15:10 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:2cf89ae83225f932b226cd57ef2d083a59bcf8a3

commit r15-2789-g2cf89ae83225f932b226cd57ef2d083a59bcf8a3
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Aug 6 14:56:26 2024 +0200

    tree-optimization/116166 - forward jump-threading going wild
    
    Currently the forward threader isn't limited as to the search space
    it explores and with it now using path-ranger for simplifying
    conditions it runs into it became pretty slow for degenerate cases
    like compiling insn-emit.cc for RISC-V esp. when compiling for
    a host with LOGICAL_OP_NON_SHORT_CIRCUIT disabled.
    
    The following makes the forward threader honor the search space
    limit I introduced for the backward threader.  This reduces
    compile-time from minutes to seconds for the testcase in PR116166.
    
    Note this wasn't necessary before we had ranger but with ranger
    the work we do is quadatic in the length of the threading path
    we build up (the same is true for the backwards threader).
    
            PR tree-optimization/116166
            * tree-ssa-threadedge.h (jump_threader::thread_around_empty_blocks):
            Add limit parameter.
            (jump_threader::thread_through_normal_block): Likewise.
            * tree-ssa-threadedge.cc (jump_threader::thread_around_empty_blocks):
            Honor and decrement limit parameter.
            (jump_threader::thread_through_normal_block): Likewise.
            (jump_threader::thread_across_edge): Initialize limit from
            param_max_jump_thread_paths and pass it down to workers.
Comment 25 Richard Biener 2024-08-07 07:16:46 UTC
I think despite RISC-Vs stupid setting of LOGICAL_OP_NON_SHORT_CIRCUIT this should now be mostly mitigated.  Updated (native) RISC-V numbers after the rev. appreciated.
Comment 26 Mark Wielaard 2024-08-07 10:38:27 UTC
With gcc-15-2791-g2083389a18d native build of the preprocessed insn-emit-96.cc from attachment #1 goes from 6 hours to 5 minutes.

Time variable                                   usr           sys          wall           GGC
 phase setup                        :   0.04 (  0%)   0.02 (  0%)   0.05 (  0%)  2844k (  0%)
 phase parsing                      :  11.98 (  4%)  10.66 ( 47%)  22.73 (  7%)   306M ( 47%)
 phase lang. deferred               :   0.20 (  0%)   0.01 (  0%)   0.22 (  0%)  2970k (  0%)
 phase opt and generate             : 278.46 ( 96%)  11.75 ( 52%) 291.62 ( 93%)   346M ( 53%)
 phase last asm                     :   0.01 (  0%)   0.01 (  0%)   0.02 (  0%)    69k (  0%)
 phase finalize                     :   0.00 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 |name lookup                       :   2.16 (  1%)   1.64 (  7%)   3.94 (  1%)  4335k (  1%)
 |overload resolution               :   2.15 (  1%)   1.33 (  6%)   3.28 (  1%)    30M (  5%)
 garbage collection                 :   0.92 (  0%)   1.84 (  8%)   2.76 (  1%)     0  (  0%)
 dump files                         :   0.85 (  0%)   0.18 (  1%)   1.02 (  0%)     0  (  0%)
 callgraph construction             :   0.46 (  0%)   0.04 (  0%)   0.54 (  0%)  4404k (  1%)
 callgraph optimization             :   0.41 (  0%)   0.06 (  0%)   0.53 (  0%)   108k (  0%)
 callgraph functions expansion      : 261.74 ( 90%)  10.47 ( 47%) 273.55 ( 87%)   264M ( 40%)
 callgraph ipa passes               :  15.34 (  5%)   1.17 (  5%)  16.57 (  5%)    29M (  4%)
 ipa function summary               :   0.34 (  0%)   0.02 (  0%)   0.31 (  0%)  1513k (  0%)
 ipa dead code removal              :   0.02 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 ipa inheritance graph              :   0.01 (  0%)   0.00 (  0%)   0.00 (  0%)   152  (  0%)
 ipa devirtualization               :   0.01 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 ipa cp                             :   0.15 (  0%)   0.02 (  0%)   0.19 (  0%)   695k (  0%)
 ipa inlining heuristics            :   0.10 (  0%)   0.10 (  0%)   0.26 (  0%)   345k (  0%)
 ipa function splitting             :   0.21 (  0%)   0.00 (  0%)   0.14 (  0%)    52k (  0%)
 ipa comdats                        :   0.01 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 ipa various optimizations          :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 ipa reference                      :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 ipa pure const                     :   0.15 (  0%)   0.02 (  0%)   0.15 (  0%)     0  (  0%)
 ipa icf                            :   0.11 (  0%)   0.00 (  0%)   0.11 (  0%)     0  (  0%)
 ipa SRA                            :   0.14 (  0%)   0.00 (  0%)   0.15 (  0%)   137k (  0%)
 ipa free lang data                 :   0.01 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 ipa modref                         :   0.11 (  0%)   0.00 (  0%)   0.12 (  0%)   541k (  0%)
 cfg construction                   :   0.35 (  0%)   0.10 (  0%)   0.40 (  0%)    11M (  2%)
 cfg cleanup                        :   3.59 (  1%)   0.10 (  0%)   3.81 (  1%)  2215k (  0%)
 trivially dead code                :   0.55 (  0%)   0.04 (  0%)   0.53 (  0%)     0  (  0%)
 df scan insns                      :   0.46 (  0%)   0.06 (  0%)   0.43 (  0%)    88k (  0%)
 df reaching defs                   :   0.81 (  0%)   0.06 (  0%)   0.82 (  0%)     0  (  0%)
 df live regs                       :   4.37 (  2%)   0.27 (  1%)   4.54 (  1%)     0  (  0%)
 df live&initialized regs           :   2.34 (  1%)   0.08 (  0%)   2.54 (  1%)     0  (  0%)
 df must-initialized regs           :   0.18 (  0%)   0.00 (  0%)   0.16 (  0%)     0  (  0%)
 df use-def / def-use chains        :   0.32 (  0%)   0.02 (  0%)   0.37 (  0%)     0  (  0%)
 df reg dead/unused notes           :   2.11 (  1%)   0.11 (  0%)   2.07 (  1%)  2691k (  0%)
 register information               :   1.09 (  0%)   0.14 (  1%)   1.24 (  0%)     0  (  0%)
 alias analysis                     :   1.64 (  1%)   0.10 (  0%)   1.91 (  1%)  9836k (  1%)
 alias stmt walking                 :   0.16 (  0%)   0.05 (  0%)   0.15 (  0%)     0  (  0%)
 register scan                      :   0.13 (  0%)   0.01 (  0%)   0.16 (  0%)    59k (  0%)
 rebuild jump labels                :   0.33 (  0%)   0.02 (  0%)   0.24 (  0%)     0  (  0%)
 preprocessing                      :   0.98 (  0%)   2.08 (  9%)   3.00 (  1%)    26M (  4%)
 parser (global)                    :   3.80 (  1%)   4.47 ( 20%)   8.31 (  3%)   175M ( 27%)
 parser struct body                 :   0.32 (  0%)   0.09 (  0%)   0.38 (  0%)  6856k (  1%)
 parser enumerator list             :   0.22 (  0%)   0.22 (  1%)   0.46 (  0%)  8060k (  1%)
 parser function body               :   4.28 (  1%)   2.47 ( 11%)   7.02 (  2%)    61M (  9%)
 parser inl. func. body             :   0.78 (  0%)   0.36 (  2%)   1.23 (  0%)    12M (  2%)
 parser inl. meth. body             :   0.23 (  0%)   0.09 (  0%)   0.33 (  0%)  3821k (  1%)
 template instantiation             :   1.15 (  0%)   0.63 (  3%)   1.63 (  1%)    16M (  2%)
 constant expression evaluation     :   0.37 (  0%)   0.18 (  1%)   0.45 (  0%)   192k (  0%)
 early inlining heuristics          :   0.04 (  0%)   0.00 (  0%)   0.17 (  0%)   950k (  0%)
 inline parameters                  :   0.68 (  0%)   0.09 (  0%)   0.73 (  0%)  2386k (  0%)
 integration                        :   0.37 (  0%)   0.12 (  1%)   0.44 (  0%)  4810k (  1%)
 tree gimplify                      :   0.48 (  0%)   0.06 (  0%)   0.51 (  0%)    28M (  4%)
 tree eh                            :   0.07 (  0%)   0.01 (  0%)   0.04 (  0%)    26k (  0%)
 tree CFG construction              :   0.21 (  0%)   0.01 (  0%)   0.28 (  0%)    20M (  3%)
 tree CFG cleanup                   :   3.66 (  1%)   0.30 (  1%)   4.08 (  1%)   549k (  0%)
 tree tail merge                    :   0.36 (  0%)   0.07 (  0%)   0.47 (  0%)  5109k (  1%)
 tree VRP                           :   6.64 (  2%)   0.20 (  1%)   6.95 (  2%)  1976k (  0%)
 tree Early VRP                     :   6.31 (  2%)   0.11 (  0%)   6.35 (  2%)  1108k (  0%)
 tree copy propagation              :   0.30 (  0%)   0.04 (  0%)   0.46 (  0%)     0  (  0%)
 tree PTA                           :   0.85 (  0%)   0.24 (  1%)   0.99 (  0%)   906k (  0%)
 tree SSA other                     :   0.00 (  0%)   0.01 (  0%)   0.02 (  0%)     0  (  0%)
 tree SSA rewrite                   :   0.17 (  0%)   0.17 (  1%)   0.31 (  0%)  4584k (  1%)
 tree SSA incremental               :   0.13 (  0%)   0.01 (  0%)   0.16 (  0%)   222k (  0%)
 tree operand scan                  :   0.83 (  0%)   0.23 (  1%)   0.81 (  0%)    10M (  2%)
 dominator optimization             :  98.73 ( 34%)   0.91 (  4%)  99.99 ( 32%)    17M (  3%)
 backwards jump threading           :  60.42 ( 21%)   0.76 (  3%)  61.86 ( 20%)    39M (  6%)
 tree SRA                           :   0.01 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 isolate eroneous paths             :   0.08 (  0%)   0.00 (  0%)   0.04 (  0%)     0  (  0%)
 tree CCP                           :   1.75 (  1%)   0.14 (  1%)   1.95 (  1%)   930k (  0%)
 tree split crit edges              :   0.11 (  0%)   0.01 (  0%)   0.13 (  0%)  4548k (  1%)
 tree reassociation                 :   0.19 (  0%)   0.02 (  0%)   0.16 (  0%)    27k (  0%)
 tree PRE                           :   1.33 (  0%)   0.23 (  1%)   1.55 (  0%) 10068k (  1%)
 tree FRE                           :   2.47 (  1%)   0.27 (  1%)   2.88 (  1%)  1125k (  0%)
 tree code sinking                  :   0.39 (  0%)   0.09 (  0%)   0.39 (  0%)  9581k (  1%)
 tree linearize phis                :   0.20 (  0%)   0.02 (  0%)   0.18 (  0%)  1090k (  0%)
 tree backward propagate            :   0.01 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 tree forward propagate             :   0.76 (  0%)   0.08 (  0%)   0.83 (  0%)   171k (  0%)
 tree phiprop                       :   0.08 (  0%)   0.00 (  0%)   0.09 (  0%)     0  (  0%)
 tree conservative DCE              :   0.16 (  0%)   0.02 (  0%)   0.28 (  0%)     0  (  0%)
 tree aggressive DCE                :   0.29 (  0%)   0.04 (  0%)   0.28 (  0%)  2094k (  0%)
 tree buildin call DCE              :   0.03 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 tree DSE                           :   0.19 (  0%)   0.02 (  0%)   0.27 (  0%)  8272  (  0%)
 PHI merge                          :   0.05 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 tree loop optimization             :   0.00 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 tree loop invariant motion         :   0.01 (  0%)   0.01 (  0%)   0.01 (  0%)     0  (  0%)
 complete unrolling                 :   0.00 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 tree slp vectorization             :   0.30 (  0%)   0.09 (  0%)   0.38 (  0%)  3311k (  0%)
 tree copy headers                  :   0.03 (  0%)   0.00 (  0%)   0.02 (  0%)   984k (  0%)
 tree SSA uncprop                   :   0.16 (  0%)   0.01 (  0%)   0.23 (  0%)     0  (  0%)
 tree NRV optimization              :   0.00 (  0%)   0.00 (  0%)   0.01 (  0%)    42k (  0%)
 tree switch conversion             :   0.04 (  0%)   0.00 (  0%)   0.08 (  0%)   554k (  0%)
 tree switch lowering               :   0.02 (  0%)   0.00 (  0%)   0.02 (  0%)    99k (  0%)
 gimple expand pow                  :   0.00 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 gimple widening/fma detection      :   0.01 (  0%)   0.00 (  0%)   0.08 (  0%)    43k (  0%)
 tree strlen optimization           :   0.09 (  0%)   0.01 (  0%)   0.16 (  0%)   984k (  0%)
 tree modref                        :   0.24 (  0%)   0.03 (  0%)   0.42 (  0%)  1012k (  0%)
 dominance frontiers                :   0.16 (  0%)   0.00 (  0%)   0.19 (  0%)     0  (  0%)
 dominance computation              :   4.05 (  1%)   0.18 (  1%)   4.02 (  1%)     0  (  0%)
 control dependences                :   0.02 (  0%)   0.00 (  0%)   0.04 (  0%)     0  (  0%)
 out of ssa                         :   0.15 (  0%)   0.01 (  0%)   0.25 (  0%)   365k (  0%)
 expand vars                        :   0.05 (  0%)   0.01 (  0%)   0.05 (  0%)   225k (  0%)
 expand                             :   1.49 (  1%)   0.43 (  2%)   1.70 (  1%)    31M (  5%)
 post expand cleanups               :   0.54 (  0%)   0.09 (  0%)   0.71 (  0%)  9495k (  1%)
 varconst                           :   0.05 (  0%)   0.08 (  0%)   0.12 (  0%)  4864  (  0%)
 lower subreg                       :   0.01 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 jump                               :   0.02 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 forward prop                       :   1.21 (  0%)   0.09 (  0%)   1.39 (  0%)    71k (  0%)
 CSE                                :   3.10 (  1%)   0.27 (  1%)   3.49 (  1%)   187k (  0%)
 dead code elimination              :   0.56 (  0%)   0.02 (  0%)   0.67 (  0%)     0  (  0%)
 dead store elim1                   :   0.37 (  0%)   0.02 (  0%)   0.36 (  0%)   490k (  0%)
 dead store elim2                   :   0.58 (  0%)   0.04 (  0%)   0.66 (  0%)  1519k (  0%)
 loop analysis                      :   0.02 (  0%)   0.01 (  0%)   0.01 (  0%)     0  (  0%)
 loop init                          :   1.67 (  1%)   0.11 (  0%)   1.63 (  1%)  3446k (  1%)
 loop fini                          :   0.23 (  0%)   0.05 (  0%)   0.17 (  0%)     0  (  0%)
 CPROP                              :   6.33 (  2%)   0.18 (  1%)   6.72 (  2%)    10M (  2%)
 PRE                                :   0.29 (  0%)   0.01 (  0%)   0.33 (  0%)   132k (  0%)
 auto inc dec                       :   0.06 (  0%)   0.01 (  0%)   0.15 (  0%)    22k (  0%)
 CSE 2                              :   2.12 (  1%)   0.12 (  1%)   2.22 (  1%)    68k (  0%)
 branch prediction                  :   0.31 (  0%)   0.04 (  0%)   0.36 (  0%)   127k (  0%)
 combiner                           :   1.50 (  1%)   0.10 (  0%)   1.70 (  1%)  2482k (  0%)
 if-conversion                      :   0.77 (  0%)   0.08 (  0%)   0.75 (  0%)  2882k (  0%)
 mode switching                     :   0.00 (  0%)   0.01 (  0%)   0.02 (  0%)     0  (  0%)
 scheduling                         :  16.02 (  6%)   0.32 (  1%)  16.46 (  5%)  2475k (  0%)
 integrated RA                      :   4.43 (  2%)   0.23 (  1%)   4.65 (  1%)    39M (  6%)
 LRA non-specific                   :   1.60 (  1%)   0.02 (  0%)   1.74 (  1%)   430k (  0%)
 LRA virtuals elimination           :   1.52 (  1%)   0.01 (  0%)   1.54 (  0%)   283k (  0%)
 LRA reload inheritance             :   0.33 (  0%)   0.01 (  0%)   0.25 (  0%)   176k (  0%)
 LRA create live ranges             :   0.38 (  0%)   0.00 (  0%)   0.44 (  0%)   105k (  0%)
 LRA hard reg assignment            :   0.13 (  0%)   0.01 (  0%)   0.07 (  0%)     0  (  0%)
 LRA rematerialization              :   0.08 (  0%)   0.03 (  0%)   0.11 (  0%)     0  (  0%)
 reload                             :   0.06 (  0%)   0.01 (  0%)   0.09 (  0%)    38k (  0%)
 reload CSE regs                    :   1.20 (  0%)   0.04 (  0%)   1.31 (  0%)  1997k (  0%)
 ree                                :   0.32 (  0%)   0.01 (  0%)   0.25 (  0%)  1880  (  0%)
 thread pro- & epilogue             :   1.14 (  0%)   0.07 (  0%)   1.10 (  0%)  2690k (  0%)
 if-conversion 2                    :   0.17 (  0%)   0.01 (  0%)   0.16 (  0%)  1560  (  0%)
 peephole 2                         :   0.26 (  0%)   0.00 (  0%)   0.20 (  0%)     0  (  0%)
 hard reg cprop                     :   0.53 (  0%)   0.14 (  1%)   0.68 (  0%)  5568  (  0%)
 scheduling 2                       :   2.67 (  1%)   0.10 (  0%)   2.82 (  1%)   481k (  0%)
 machine dep reorg                  :   0.02 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 reorder blocks                     :   0.67 (  0%)   0.03 (  0%)   0.76 (  0%)  4364k (  1%)
 shorten branches                   :   0.30 (  0%)   0.02 (  0%)   0.28 (  0%)     0  (  0%)
 final                              :   0.95 (  0%)   0.13 (  1%)   1.05 (  0%)  4363k (  1%)
 symout                             :   0.00 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 tree if-combine                    :   0.08 (  0%)   0.00 (  0%)   0.06 (  0%)  2800  (  0%)
 if to switch conversion            :   0.13 (  0%)   0.00 (  0%)   0.19 (  0%)  1649k (  0%)
 straight-line strength reduction   :   0.05 (  0%)   0.00 (  0%)   0.08 (  0%)    54k (  0%)
 store merging                      :   0.02 (  0%)   0.00 (  0%)   0.01 (  0%)    17k (  0%)
 initialize rtl                     :   0.04 (  0%)   0.00 (  0%)   0.05 (  0%)    18k (  0%)
 address lowering                   :   0.01 (  0%)   0.01 (  0%)   0.00 (  0%)     0  (  0%)
 access analysis                    :   0.39 (  0%)   0.08 (  0%)   0.47 (  0%)   168  (  0%)
 rest of compilation                :   7.22 (  2%)   0.66 (  3%)   7.74 (  2%)    17M (  3%)
 unaccounted late compilation       :   0.01 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 remove unused locals               :   0.14 (  0%)   0.03 (  0%)   0.22 (  0%)     0  (  0%)
 address taken                      :   0.21 (  0%)   0.01 (  0%)   0.22 (  0%)     0  (  0%)
 rebuild frequencies                :   0.02 (  0%)   0.00 (  0%)   0.04 (  0%)     0  (  0%)
 repair loop structures             :   0.04 (  0%)   0.02 (  0%)   0.08 (  0%)     0  (  0%)
 TOTAL                              : 290.69         22.46        314.65          658M
Comment 27 Mark Wielaard 2024-08-07 16:41:04 UTC
With gcc-15-2794-g5b999997d1a most insn-*.cc files compile in minutes.
The only exception is insn-recog.cc which takes 85 minutes (1 hour 25 minutes).

Time variable                                   usr           sys          wall           GGC
 phase setup                        :   0.07 (  0%)   0.04 (  0%)   0.11 (  0%)  2844k (  0%)
 phase parsing                      : 201.81 (  4%)  42.93 ( 28%) 245.90 (  5%)  1189M ( 21%)
 phase lang. deferred               :   0.38 (  0%)   0.05 (  0%)   0.43 (  0%)  2659k (  0%)
 phase opt and generate             :4774.72 ( 96%) 109.82 ( 72%)4907.10 ( 95%)  4440M ( 79%)
 phase last asm                     :   0.03 (  0%)   0.00 (  0%)   0.03 (  0%)    48  (  0%)
 |name lookup                       :  14.27 (  0%)   2.80 (  2%)  16.63 (  0%)  4296k (  0%)
 |overload resolution               :  36.86 (  1%)   5.25 (  3%)  41.14 (  1%)   135M (  2%)
 garbage collection                 :  14.27 (  0%)   4.73 (  3%)  19.06 (  0%)     0  (  0%)
 dump files                         :   2.16 (  0%)   0.08 (  0%)   2.16 (  0%)     0  (  0%)
 callgraph construction             :  44.76 (  1%)   4.36 (  3%)  49.32 (  1%)   530M (  9%)
 callgraph optimization             :  11.08 (  0%)   2.23 (  1%)  13.63 (  0%)    59k (  0%)
 callgraph functions expansion      :4033.43 ( 81%)  75.70 ( 50%)4128.66 ( 80%)  3151M ( 56%)
 callgraph ipa passes               : 665.59 ( 13%)  31.14 ( 20%) 699.38 ( 14%)   456M (  8%)
 ipa function summary               :  14.36 (  0%)   0.28 (  0%)  14.82 (  0%)    15M (  0%)
 ipa dead code removal              :   1.39 (  0%)   0.02 (  0%)   1.37 (  0%)     0  (  0%)
 ipa inheritance graph              :   0.02 (  0%)   0.00 (  0%)   0.02 (  0%)   152  (  0%)
 ipa devirtualization               :   0.02 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 ipa cp                             :   7.86 (  0%)   0.37 (  0%)   8.33 (  0%)  9201k (  0%)
 ipa inlining heuristics            :   7.76 (  0%)   0.59 (  0%)   8.24 (  0%)    28M (  1%)
 ipa function splitting             :   0.55 (  0%)   0.03 (  0%)   0.66 (  0%)    36k (  0%)
 ipa comdats                        :   0.09 (  0%)   0.00 (  0%)   0.08 (  0%)     0  (  0%)
 ipa various optimizations          :   0.02 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 ipa reference                      :   0.18 (  0%)   0.00 (  0%)   0.18 (  0%)     0  (  0%)
 ipa profile                        :   0.06 (  0%)   0.00 (  0%)   0.06 (  0%)     0  (  0%)
 ipa pure const                     :   4.89 (  0%)   0.17 (  0%)   5.00 (  0%)  9648  (  0%)
 ipa icf                            :   8.30 (  0%)   1.88 (  1%)  10.22 (  0%)     0  (  0%)
 ipa SRA                            :  95.18 (  2%)   1.04 (  1%)  96.50 (  2%)    16M (  0%)
 ipa free lang data                 :   0.02 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 ipa free inline summary            :   0.18 (  0%)   0.02 (  0%)   0.20 (  0%)     0  (  0%)
 ipa modref                         :   8.55 (  0%)   0.05 (  0%)   8.62 (  0%)  3720k (  0%)
 cfg construction                   :   1.83 (  0%)   0.04 (  0%)   1.93 (  0%)    14M (  0%)
 cfg cleanup                        :  54.36 (  1%)   0.85 (  1%)  55.83 (  1%)    23M (  0%)
 trivially dead code                :  14.16 (  0%)   0.13 (  0%)  14.18 (  0%)     0  (  0%)
 df scan insns                      :  25.06 (  1%)   0.35 (  0%)  25.37 (  0%)   147k (  0%)
 df reaching defs                   :  20.26 (  0%)   0.17 (  0%)  20.15 (  0%)     0  (  0%)
 df live regs                       : 143.04 (  3%)   2.10 (  1%) 145.64 (  3%)     0  (  0%)
 df live&initialized regs           :  75.37 (  2%)   0.93 (  1%)  77.70 (  2%)     0  (  0%)
 df must-initialized regs           :   2.80 (  0%)   0.02 (  0%)   3.04 (  0%)     0  (  0%)
 df use-def / def-use chains        :   9.87 (  0%)   0.06 (  0%)  10.06 (  0%)     0  (  0%)
 df reg dead/unused notes           :  47.82 (  1%)   1.04 (  1%)  48.15 (  1%)    46M (  1%)
 register information               :  64.50 (  1%)   0.88 (  1%)  66.26 (  1%)     0  (  0%)
 alias analysis                     :  46.03 (  1%)   0.51 (  0%)  47.00 (  1%)   202M (  4%)
 alias stmt walking                 :  30.76 (  1%)   1.98 (  1%)  30.73 (  1%)   106k (  0%)
 register scan                      :   5.85 (  0%)   0.09 (  0%)   6.14 (  0%)  2405k (  0%)
 rebuild jump labels                :   5.38 (  0%)   0.15 (  0%)   5.76 (  0%)    96  (  0%)
 preprocessing                      :  13.40 (  0%)  11.45 (  7%)  25.81 (  1%)   245M (  4%)
 parser (global)                    :  19.44 (  0%)   9.54 (  6%)  28.47 (  1%)   362M (  6%)
 parser struct body                 :   1.20 (  0%)   0.18 (  0%)   1.29 (  0%)  5784k (  0%)
 parser enumerator list             :   0.66 (  0%)   0.26 (  0%)   0.88 (  0%)  7976k (  0%)
 parser function body               : 151.50 (  3%)  19.39 ( 13%) 172.99 (  3%)   539M ( 10%)
 parser inl. func. body             :   1.93 (  0%)   0.42 (  0%)   2.36 (  0%)  9507k (  0%)
 parser inl. meth. body             :   0.64 (  0%)   0.09 (  0%)   0.77 (  0%)  3852k (  0%)
 template instantiation             :   2.24 (  0%)   0.31 (  0%)   2.31 (  0%)    10M (  0%)
 constant expression evaluation     :   8.57 (  0%)   1.23 (  1%)   8.77 (  0%)  7980k (  0%)
 early inlining heuristics          :   0.68 (  0%)   0.07 (  0%)   0.84 (  0%)  4002k (  0%)
 inline parameters                  :  31.55 (  1%)   1.44 (  1%)  32.94 (  1%)    36M (  1%)
 integration                        :   8.71 (  0%)   1.90 (  1%)  10.95 (  0%)    72M (  1%)
 tree gimplify                      :  42.44 (  1%)   1.46 (  1%)  43.95 (  1%)   374M (  7%)
 tree eh                            :   1.11 (  0%)   0.07 (  0%)   0.93 (  0%)   190k (  0%)
 tree CFG construction              :  14.24 (  0%)   0.67 (  0%)  15.15 (  0%)   142M (  3%)
 tree CFG cleanup                   : 176.13 (  4%)   4.53 (  3%) 182.05 (  4%)  9894k (  0%)
 tree tail merge                    :  44.68 (  1%)   0.47 (  0%)  45.54 (  1%)    10M (  0%)
 tree VRP                           : 192.47 (  4%)   3.06 (  2%) 196.69 (  4%)  3594k (  0%)
 tree Early VRP                     :  96.27 (  2%)   1.78 (  1%)  97.99 (  2%)    13M (  0%)
 warn array bounds                  :   7.61 (  0%)   0.23 (  0%)   7.83 (  0%)   600  (  0%)
 tree copy propagation              :  20.83 (  0%)   0.12 (  0%)  20.73 (  0%)    55k (  0%)
 tree PTA                           :  90.67 (  2%)   1.76 (  1%)  92.89 (  2%)    17M (  0%)
 tree SSA other                     :   0.11 (  0%)   0.07 (  0%)   0.12 (  0%)   128k (  0%)
 tree SSA rewrite                   :   9.23 (  0%)   2.02 (  1%)  11.28 (  0%)    93M (  2%)
 tree SSA incremental               :  16.83 (  0%)   0.86 (  1%)  17.78 (  0%)    32M (  1%)
 tree operand scan                  :  17.74 (  0%)   2.77 (  2%)  18.92 (  0%)    94M (  2%)
 dominator optimization             : 213.28 (  4%)   3.44 (  2%) 218.36 (  4%)    56M (  1%)
 backwards jump threading           :  90.52 (  2%)   2.16 (  1%)  93.76 (  2%)    46M (  1%)
 tree SRA                           :   1.10 (  0%)   0.05 (  0%)   1.20 (  0%)   627k (  0%)
 isolate eroneous paths             :   1.48 (  0%)   0.00 (  0%)   1.76 (  0%)     0  (  0%)
 tree CCP                           : 183.30 (  4%)   3.36 (  2%) 187.40 (  4%)    26M (  0%)
 tree split crit edges              :   2.34 (  0%)   0.12 (  0%)   2.68 (  0%)    51M (  1%)
 tree reassociation                 :  14.64 (  0%)   0.48 (  0%)  15.40 (  0%)  7866k (  0%)
 tree PRE                           : 112.43 (  2%)   2.99 (  2%) 116.25 (  2%)    61M (  1%)
 tree FRE                           : 221.27 (  4%)   6.88 (  5%) 230.52 (  4%)    31M (  1%)
 tree code sinking                  :  11.74 (  0%)   0.26 (  0%)  11.44 (  0%)    98M (  2%)
 tree linearize phis                :   9.25 (  0%)   0.22 (  0%)   9.30 (  0%)  8182k (  0%)
 tree backward propagate            :   1.21 (  0%)   0.08 (  0%)   1.30 (  0%)     0  (  0%)
 tree forward propagate             : 102.22 (  2%)   4.62 (  3%) 107.44 (  2%)    28M (  1%)
 tree phiprop                       :   0.67 (  0%)   0.02 (  0%)   0.76 (  0%)     0  (  0%)
 tree conservative DCE              :  10.38 (  0%)   1.09 (  1%)  11.85 (  0%)   347k (  0%)
 tree aggressive DCE                :   9.43 (  0%)   0.69 (  0%)  10.02 (  0%)    11M (  0%)
 tree buildin call DCE              :   0.37 (  0%)   0.01 (  0%)   0.23 (  0%)     0  (  0%)
 tree DSE                           :  13.35 (  0%)   0.14 (  0%)  13.90 (  0%)  2185k (  0%)
 PHI merge                          :   8.07 (  0%)   0.17 (  0%)   8.32 (  0%)    75M (  1%)
 loopless fn                        :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 tree loop invariant motion         :   0.12 (  0%)   0.00 (  0%)   0.08 (  0%)     0  (  0%)
 complete unrolling                 :   0.67 (  0%)   0.04 (  0%)   0.70 (  0%)  1957k (  0%)
 tree slp vectorization             :  48.85 (  1%)   0.71 (  0%)  49.97 (  1%)   105M (  2%)
 tree loop distribution             :   0.02 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 tree iv optimization               :   0.01 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 tree copy headers                  :   0.16 (  0%)   0.00 (  0%)   0.21 (  0%)  1650k (  0%)
 tree SSA uncprop                   :   5.00 (  0%)   0.03 (  0%)   4.93 (  0%)     0  (  0%)
 tree NRV optimization              :   0.03 (  0%)   0.00 (  0%)   0.01 (  0%)    73k (  0%)
 tree switch conversion             :   0.29 (  0%)   0.00 (  0%)   0.32 (  0%)    12k (  0%)
 tree switch lowering               :  12.54 (  0%)   0.19 (  0%)  12.52 (  0%)  9840k (  0%)
 gimple CSE sin/cos                 :   0.23 (  0%)   0.00 (  0%)   0.23 (  0%)     0  (  0%)
 gimple expand pow                  :   0.28 (  0%)   0.01 (  0%)   0.32 (  0%)     0  (  0%)
 gimple widening/fma detection      :   1.30 (  0%)   0.01 (  0%)   1.31 (  0%)  4304  (  0%)
 tree strlen optimization           :   3.14 (  0%)   0.11 (  0%)   3.25 (  0%)  1650k (  0%)
 tree modref                        :  17.07 (  0%)   0.42 (  0%)  17.48 (  0%)  3924k (  0%)
 dominance frontiers                :   2.40 (  0%)   0.03 (  0%)   2.31 (  0%)     0  (  0%)
 dominance computation              :  42.96 (  1%)   1.32 (  1%)  44.22 (  1%)     0  (  0%)
 control dependences                :   0.86 (  0%)   0.01 (  0%)   1.14 (  0%)     0  (  0%)
 out of ssa                         :   7.51 (  0%)   0.31 (  0%)   7.75 (  0%)   496k (  0%)
 expand vars                        :   2.09 (  0%)   0.10 (  0%)   2.29 (  0%)    35M (  1%)
 expand                             :  61.39 (  1%)   1.28 (  1%)  63.15 (  1%)   435M (  8%)
 post expand cleanups               :   5.77 (  0%)   0.13 (  0%)   5.83 (  0%)    10M (  0%)
 varconst                           :   0.14 (  0%)   0.02 (  0%)   0.12 (  0%)  4736  (  0%)
 lower subreg                       :   0.27 (  0%)   0.00 (  0%)   0.42 (  0%)    32k (  0%)
 jump                               :   0.06 (  0%)   0.00 (  0%)   0.07 (  0%)     0  (  0%)
 forward prop                       :  88.69 (  2%)   1.83 (  1%)  91.11 (  2%)  9609k (  0%)
 CSE                                : 132.51 (  3%)   1.59 (  1%) 134.71 (  3%)    22M (  0%)
 dead code elimination              :  11.19 (  0%)   0.12 (  0%)  11.24 (  0%)     0  (  0%)
 dead store elim1                   :  16.56 (  0%)   0.31 (  0%)  16.77 (  0%)    28M (  1%)
 dead store elim2                   :  20.72 (  0%)   0.54 (  0%)  21.41 (  0%)    37M (  1%)
 loop analysis                      :   0.07 (  0%)   0.00 (  0%)   0.08 (  0%)     0  (  0%)
 loop init                          :  27.46 (  1%)   0.43 (  0%)  28.37 (  1%)  7214k (  0%)
 loop invariant motion              :   0.01 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 loop fini                          :   0.80 (  0%)   0.04 (  0%)   0.59 (  0%)     0  (  0%)
 CPROP                              :  98.14 (  2%)   1.92 (  1%) 100.95 (  2%)   262M (  5%)
 PRE                                :  42.88 (  1%)   1.09 (  1%)  44.10 (  1%)  9792k (  0%)
 auto inc dec                       :   2.52 (  0%)   0.10 (  0%)   2.67 (  0%)    36k (  0%)
 CSE 2                              :  64.22 (  1%)   0.64 (  0%)  65.41 (  1%)    12M (  0%)
 branch prediction                  :  10.67 (  0%)   0.36 (  0%)  11.46 (  0%)   337k (  0%)
 combiner                           : 300.17 (  6%)   3.36 (  2%) 304.85 (  6%)   425M (  8%)
 if-conversion                      :  25.07 (  1%)   0.27 (  0%)  25.71 (  0%)  6340k (  0%)
 mode switching                     :   0.03 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 scheduling                         : 491.00 ( 10%)   5.34 (  3%) 498.79 ( 10%)    44M (  1%)
 early rematerialization            :   0.03 (  0%)   0.00 (  0%)   0.03 (  0%)     0  (  0%)
 integrated RA                      : 119.97 (  2%)   1.68 (  1%) 122.07 (  2%)   374M (  7%)
 LRA non-specific                   :  37.88 (  1%)   0.27 (  0%)  38.08 (  1%) 10047k (  0%)
 LRA virtuals elimination           :   5.95 (  0%)   0.06 (  0%)   6.45 (  0%)  1570k (  0%)
 LRA reload inheritance             :   9.36 (  0%)   0.39 (  0%)   9.84 (  0%)  6100k (  0%)
 LRA create live ranges             :  25.13 (  1%)   0.21 (  0%)  25.54 (  0%)  5299k (  0%)
 LRA hard reg assignment            :   4.63 (  0%)   0.17 (  0%)   4.69 (  0%)     0  (  0%)
 LRA rematerialization              :   3.61 (  0%)   0.08 (  0%)   3.57 (  0%)     0  (  0%)
 reload                             :   0.79 (  0%)   0.00 (  0%)   0.87 (  0%)    44k (  0%)
 reload CSE regs                    :  56.34 (  1%)   0.80 (  1%)  57.30 (  1%)    38M (  1%)
 ree                                :   4.83 (  0%)   0.02 (  0%)   4.73 (  0%)    29k (  0%)
 thread pro- & epilogue             :  64.91 (  1%)   0.58 (  0%)  65.81 (  1%)    65M (  1%)
 if-conversion 2                    :   1.88 (  0%)   0.01 (  0%)   1.77 (  0%)     0  (  0%)
 peephole 2                         :   4.78 (  0%)   0.03 (  0%)   4.40 (  0%)     0  (  0%)
 hard reg cprop                     :  11.63 (  0%)   0.57 (  0%)  12.27 (  0%)    79k (  0%)
 scheduling 2                       :  98.90 (  2%)   1.16 (  1%) 100.28 (  2%)  1415k (  0%)
 reorder blocks                     :  12.49 (  0%)   0.22 (  0%)  12.84 (  0%)    32M (  1%)
 shorten branches                   :   7.99 (  0%)   0.26 (  0%)   8.39 (  0%)     0  (  0%)
 final                              :  23.59 (  0%)   0.66 (  0%)  24.54 (  0%)    66M (  1%)
 symout                             :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 tree if-combine                    :   0.81 (  0%)   0.15 (  0%)   1.17 (  0%)    37k (  0%)
 if to switch conversion            :   2.50 (  0%)   0.06 (  0%)   2.48 (  0%)  5360  (  0%)
 uninit var analysis                :   5.28 (  0%)   0.71 (  0%)   6.15 (  0%)     0  (  0%)
 straight-line strength reduction   :   3.70 (  0%)   0.07 (  0%)   3.61 (  0%)    34k (  0%)
 store merging                      :   1.55 (  0%)   0.11 (  0%)   1.56 (  0%)   330k (  0%)
 initialize rtl                     :   0.13 (  0%)   0.00 (  0%)   0.15 (  0%)    18k (  0%)
 address lowering                   :   0.13 (  0%)   0.01 (  0%)   0.10 (  0%)     0  (  0%)
 access analysis                    :  12.90 (  0%)   0.58 (  0%)  13.82 (  0%)   288  (  0%)
 early local passes                 :   0.02 (  0%)   0.00 (  0%)   0.02 (  0%)     0  (  0%)
 unaccounted optimizations          :   0.01 (  0%)   0.00 (  0%)   0.00 (  0%)     0  (  0%)
 rest of compilation                : 143.97 (  3%)   2.06 (  1%) 145.49 (  3%)    62M (  1%)
 unaccounted post reload            :   0.00 (  0%)   0.00 (  0%)   0.04 (  0%)     0  (  0%)
 unaccounted late compilation       :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)     0  (  0%)
 remove unused locals               :   8.25 (  0%)   0.75 (  0%)   9.27 (  0%)     0  (  0%)
 address taken                      :   9.41 (  0%)   0.36 (  0%)   9.82 (  0%)     0  (  0%)
 rebuild frequencies                :   0.45 (  0%)   0.01 (  0%)   0.42 (  0%)     0  (  0%)
 repair loop structures             :   0.49 (  0%)   0.02 (  0%)   0.39 (  0%)     0  (  0%)
 TOTAL                              :4977.01        152.84       5153.57         5635M

It is one large (19MB) file on risc-v. There is a bug #116146 to split it up.
Comment 28 Richard Biener 2024-08-08 08:18:53 UTC
(In reply to Mark Wielaard from comment #27)
> With gcc-15-2794-g5b999997d1a most insn-*.cc files compile in minutes.
> The only exception is insn-recog.cc which takes 85 minutes (1 hour 25
> minutes).
> 
> Time variable                                   usr           sys         
> wall           GGC
[...]
>  TOTAL                              :4977.01        152.84       5153.57    
> 5635M
> 
> It is one large (19MB) file on risc-v. There is a bug #116146 to split it up.

I'll note this is a flat profile and definitely a different "bug" (if one
at all).  I'll also note that once functions cross a certain size boundary
some data structures fall out of caches and you'll observe a general slowdown
everywhere - that's of course more pronounced on cache-starved implementations.

It might be interesting to have statistics on function sizes in
insn-recog.cc to see if there's any outliers - if it's just very many
there's nothing to do but split the file up.

> grep ^static insn-recog.cc  | wc -l
2404

so it's not obvious it's just many (that would make each function ~250 lines).
Comment 29 andi 2024-08-08 14:29:25 UTC
> It might be interesting to have statistics on function sizes in
> insn-recog.cc to see if there's any outliers - if it's just very many
> there's nothing to do but split the file up.

Or LTO doing it for you.
Comment 30 Aldy Hernandez 2024-08-26 06:05:07 UTC
(In reply to Richard Biener from comment #15)

> We're also doing a lot of redundant stmt simplifications by likely
> quadratically
> exploring jump threading paths.  And each hybrid_jt_simplifier::simplify
> call resets the path query path which we know is a very expensive operation,
> it also shares the issues the backwards threader originally had, starting
> with too big imports.  Doing that up to 2^four times for each block is
> wasteful - simplify_control_stmt_condition_1 ends up calling
> hybrid_jt_simplifier::simplify through dom_jt_simplifier::simplify and
> while simplify_control_stmt_condition_1 has a recursion limit while
> processing & and | it recurses to both arms, something ranger can do
> itself(?).

The recursion over & and | is indeed suspect, as ranger can handle all of this itself.  I suspect most of simplify_control_stmt_condition_1() can go away.  I'll look into this.

> 
> The threader JT simplifier is over-abstracted - only DOM seems to use
> hybrid_jt_simplifier.  The following should cut compile-time down
> significantly (I'm not sure if the "old" DOM equiv lookup done by
> dom-simplify is even necessary).  IMO "gimping" the old forward threader
> with ranger was misguided as it was supposed to vanish anyway.

You are correct, the use of ranger in the forward threader was a bit of a hack, but a necessary one nevertheless, as otherwise we'd need to keep the old VRP code around just for this pass.  Keeping old VRP was a maintenance burden.

The old DOM equiv lookup is still needed as it handles pointer equivalences which prange does not (yet).  It also simplifies some floating point operations that we need to audit and make sure frange handles (it probably does, I just haven't checked yet).  So yes, the old forward threader is slated for removal, but we need to address the above two items.
Comment 31 GCC Commits 2024-10-13 10:42:41 UTC
The releases/gcc-14 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:987a7b58bf2a00936ee2f418ace7c596450a17cb

commit r14-10773-g987a7b58bf2a00936ee2f418ace7c596450a17cb
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Aug 6 14:56:26 2024 +0200

    tree-optimization/116166 - forward jump-threading going wild
    
    Currently the forward threader isn't limited as to the search space
    it explores and with it now using path-ranger for simplifying
    conditions it runs into it became pretty slow for degenerate cases
    like compiling insn-emit.cc for RISC-V esp. when compiling for
    a host with LOGICAL_OP_NON_SHORT_CIRCUIT disabled.
    
    The following makes the forward threader honor the search space
    limit I introduced for the backward threader.  This reduces
    compile-time from minutes to seconds for the testcase in PR116166.
    
    Note this wasn't necessary before we had ranger but with ranger
    the work we do is quadatic in the length of the threading path
    we build up (the same is true for the backwards threader).
    
            PR tree-optimization/116166
            * tree-ssa-threadedge.h (jump_threader::thread_around_empty_blocks):
            Add limit parameter.
            (jump_threader::thread_through_normal_block): Likewise.
            * tree-ssa-threadedge.cc (jump_threader::thread_around_empty_blocks):
            Honor and decrement limit parameter.
            (jump_threader::thread_through_normal_block): Likewise.
            (jump_threader::thread_across_edge): Initialize limit from
            param_max_jump_thread_paths and pass it down to workers.
    
    (cherry picked from commit 2cf89ae83225f932b226cd57ef2d083a59bcf8a3)
Comment 32 Robin Dapp 2024-12-18 07:40:50 UTC
With insn-recog split, is this still relevant or can we close it?
Comment 33 Mark Wielaard 2024-12-18 13:06:57 UTC
(In reply to Robin Dapp from comment #32)
> With insn-recog split, is this still relevant or can we close it?

I think it is not relevant anymore, but I haven't been able to verify yet.

The current compile hog is insn-attrtab.cc which takes a couple of hours to compile.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118032
Comment 34 Mark Wielaard 2025-01-06 18:27:37 UTC
(In reply to Mark Wielaard from comment #33)
> (In reply to Robin Dapp from comment #32)
> > With insn-recog split, is this still relevant or can we close it?
> 
> I think it is not relevant anymore, but I haven't been able to verify yet.
> 
> The current compile hog is insn-attrtab.cc which takes a couple of hours to
> compile.
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118032

As just commented on that bug there is a very nice speedup somewhere after December 11 and today, when a full bootstrap test (on a 64 core riscv machine) took ~4 hours, now it takes just ~3 hours.

So lets close this bug.