[llvm] [SimpleLoopUnswitch] Record loops from unswitching non-trivial conditions (PR #141121)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 23 06:12:26 PDT 2025


antoniofrighetto wrote:

> LGTM. Thank you! Can you test this patch on llvm-test-suite to ensure that it doesn't cause performance regressions?

Sure. Test-suite baseline and loop unswitch builds set up as follows:
```
$ mkdir build && cd build
$ cmake -G Ninja -DCMAKE_C_COMPILER=/path/to/clang -C ../cmake/caches/O2.cmake ..
```
Execution time:
```
~/llvm-test-suite $ python3 ./utils/compare.py ./baseline_build/output.json ./loop_unswitch_build/output.json
Tests: 3402
Metric: exec_time

Program                                       exec_time               
                                              base      patch  diff   
SingleSource/UnitTests/testcase-Value-1         0.00      0.00    inf%
tools/fpcmp-target                              0.00      0.00    inf%
SingleSour...r/AVX512F/Vector-AVX512F-shift     0.00      0.00    inf%
SingleSour...ctor-AVX512F-roundscale_scalar     0.00      0.00    inf%
SingleSour...tor/AVX512F/Vector-AVX512F-xor     0.00      0.00    inf%
SingleSour...s/Vector/SSE/Vector-sse.isamax     0.00      0.00    inf%
SingleSour.../AVX512F/Vector-AVX512F-reduce     0.00      0.00    inf%
SingleSour...AVX512F/Vector-AVX512F-movedup     0.00      0.00    inf%
SingleSour...execute/GCC-C-execute-941014-1     0.00      0.00    inf%
SingleSour...execute/GCC-C-execute-941025-1     0.00      0.00    inf%
SingleSour...execute/GCC-C-execute-960218-1     0.00      0.00    inf%
SingleSour...execute/GCC-C-execute-960219-1     0.00      0.00    inf%
SingleSour...execute/GCC-C-execute-960301-1     0.00      0.00    inf%
SingleSour...execute/GCC-C-execute-960302-1     0.00      0.00    inf%
SingleSour...execute/GCC-C-execute-960311-2     0.00      0.00    inf%
                           Geomean difference                  -100.0%
           exec_time                            
run             base          patch         diff
count  3402.000000    3402.000000    2994.000000
mean   1772.676173    1787.095436    inf        
std    34734.073638   35483.831295  NaN         
min    0.000000       0.000000      -1.000000   
25%    0.000600       0.000000      -0.142857   
50%    0.000800       0.000800       0.000000   
75%    3.602975       3.628384       0.125000   
max    978102.897079  983259.753532  inf
```
Compile time:
```
~/llvm-test-suite $ python3 ./utils/compare.py -m compile_time ./baseline_build/output.json ./loop_unswitch_build/output.json
Tests: 3402
Metric: compile_time

Program                                       compile_time             
                                              base         patch  diff 
SingleSource/UnitTests/blockstret               0.01         0.02 43.9%
SingleSour...ce/UnitTests/2003-05-26-Shorts     0.02         0.03 42.9%
SingleSour.../UnitTests/2007-01-04-KNR-Args     0.01         0.02 38.0%
SingleSour...tTests/2020-01-06-coverage-010     0.02         0.03 32.8%
SingleSour.../UnitTests/2002-05-02-CastTest     0.03         0.03 30.8%
SingleSour...tTests/2003-09-18-BitFieldTest     0.02         0.02 28.6%
SingleSour...tTests/2020-01-06-coverage-003     0.02         0.02 25.5%
SingleSource/UnitTests/block-byref-test         0.01         0.01 25.3%
SingleSour...tTests/2002-05-02-ArgumentTest     0.01         0.02 23.5%
SingleSour...Tests/block-copied-in-cxxobj-1     0.01         0.01 22.0%
SingleSour...UnitTests/ms_struct-bitfield-1     0.02         0.02 19.2%
SingleSour...ests/ms_struct-bitfield-init-1     0.02         0.03 18.4%
MultiSourc...enchmarks/McCat/17-bintr/bintr     0.08         0.09 17.8%
SingleSour...tTests/2004-02-02-NegativeZero     0.01         0.01 17.6%
SingleSour...UnitTests/DefaultInitDynArrays     0.01         0.01 16.4%
                           Geomean difference                     -1.3%
      compile_time                         
run           base        patch        diff
count  3402.000000  3402.000000  467.000000
mean   0.212624     0.212469    -0.008679  
std    2.140155     2.140445     0.089601  
min    0.000000     0.000000    -0.442177  
25%    0.000000     0.000000    -0.031559  
50%    0.000000     0.000000    -0.002967  
75%    0.000000     0.000000     0.015789  
max    88.569200    88.710500    0.439252  
```
Overall mean:
```
mean exec_time:  1772.68s  -> 1787.10s (+0.8%)
mean compile_time: 0.213s  -> 0.212s   (‑0.1%)
```
Should be on track.

https://github.com/llvm/llvm-project/pull/141121


More information about the llvm-commits mailing list