[llvm] [SimplifyCFG] Optimize select over pointers to eliminate no-op load/store (PR #179277)

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 07:21:06 PDT 2026


hazzlim wrote:

> Hi @nikic, I did run llvm-test-suite with SPEC CPU 2017 in four configurations to actually decide if this should be a VPlan transformation only or not. For my surprise, it is even more profitable when vectorization is disabled. The four configurations are:
> 
>     * With / without vectorization (`-fno-vectorize -fno-slp-vectorize` to disable them).
> 
>     * With / without this transformation (named here MinimizeMemoryFootprint, minmemfoot in short).
> 
> 
> The execution environment is: Common flags: `-O3 -mtune=native -w` No vectorization flags: `-fno-vectorize -fno-slp-vectorize` llvm-project commit: [2c406ca](https://github.com/llvm/llvm-project/commit/2c406ca856d131a49902a2d79af615846b447872) llvm-test-suite commit: fcd86245dfa61a798bdd30082368c94c42ca77dc
> 
> ```
> lscpu
> Architecture:                x86_64
>   CPU op-mode(s):            32-bit, 64-bit
>   Address sizes:             52 bits physical, 57 bits virtual
>   Byte Order:                Little Endian
> CPU(s):                      168
>   On-line CPU(s) list:       0-167
> Vendor ID:                   AuthenticAMD
>   Model name:                AMD EPYC 9634 84-Core Processor
> ```
> 
> ```
> lsmem
> RANGE                                  SIZE  STATE REMOVABLE BLOCK
> 0x0000000000000000-0x000000587fffffff  354G online       yes 0-176
> Memory block size:         2G
> Total online memory:     354G
> ```
> 
> Below are the results for all cases where the binary hashes and execution time differ, sorted by ratio:
> 
> With vectorization:
> benchmark_name 	baseline 	minmemfoot 	difference 	ratio
> gfortran-regression-execute-regression__eoshift_3_f90 	0.0002 	0 	-0.0002 	0
> 549.fotonik3d_r 	315.0847 	264.6649 	-50.4198 	0.83998
> 620.omnetpp_s 	335.7454 	305.8903 	-29.8551 	0.911078
> 502.gcc_r 	184.6549 	172.9665 	-11.6884 	0.936701
> 602.gcc_s 	346.145 	335.2501 	-10.8949 	0.968525
> 554.roms_r 	224.8519 	219.9488 	-4.9031 	0.978194
> 649.fotonik3d_s 	651.2492 	644.4815 	-6.7677 	0.989608
> 507.cactuBSSN_r 	221.6759 	220.6687 	-1.0072 	0.995456
> 628.pop2_s 	1397.8411 	1393.4027 	-4.4384 	0.996825
> 607.cactuBSSN_s 	1841.0718 	1839.0068 	-2.065 	0.998878
> 520.omnetpp_r 	292.0097 	293.0876 	1.0779 	1.003691
> gfortran-regression-execute-regression__cshift_2_f90 	0.0035 	0.004 	0.0005 	1.142857
> gfortran-regression-execute-regression__eoshift_5_f90 	0.0017 	0.0025 	0.0008 	1.470588
> gfortran-regression-execute-regression__inline_matmul_6_f90 	0 	0.0002 	0.0002 	---
> 
> And without vectorization:
> benchmark_name 	novec-baseline 	novec-minmemfoot 	difference 	ratio
> gfortran-regression-execute-regression__cshift_2_f90 	0.0035 	0.0017 	-0.0018 	0.485714
> gfortran-regression-execute-regression__eoshift_3_f90 	0.0012 	0.0007 	-0.0005 	0.583333
> gfortran-regression-execute-regression__assumed_rank_2_f90 	0.0014 	0.001 	-0.0004 	0.714286
> 520.omnetpp_r 	385.5362 	280.3723 	-105.164 	0.727227
> gfortran-regression-execute-regression__eoshift_4_f90 	0.1507 	0.1274 	-0.0233 	0.845388
> 502.gcc_r 	181.1825 	174.691 	-6.4915 	0.964171
> 602.gcc_s 	351.6316 	340.585 	-11.0466 	0.968585
> 620.omnetpp_s 	311.3058 	304.1392 	-7.1666 	0.976979
> 549.fotonik3d_r 	301.8726 	295.2054 	-6.6672 	0.977914
> 554.roms_r 	270.0583 	265.7346 	-4.3237 	0.98399
> 649.fotonik3d_s 	708.6208 	699.5547 	-9.0661 	0.987206
> 507.cactuBSSN_r 	205.1077 	202.6421 	-2.4656 	0.987979
> 628.pop2_s 	1854.8862 	1838.4437 	-16.4425 	0.991136
> 607.cactuBSSN_s 	1699.0137 	1693.4092 	-5.6045 	0.996701
> gfortran-regression-execute-regression__eoshift_6_f90 	0.0012 	0.0017 	0.0005 	1.416667
> gfortran-regression-execute-regression__eoshift_5_f90 	0.0018 	0.0051 	0.0033 	2.833333
> gfortran-regression-execute-regression__cshift_1_f90 	0.0001 	0.0007 	0.0006 	7

Hi @dnsampaio,

These performance improvements look quite significant in some cases. Have they been reproduced? Do you have any results for LTO?

I ran the same combinations as you for SPEC on an AArch64 Neoverse V2 platform, and found no significant performance change for any benchmarks. I additionally ran an LTO build with and without this patch and saw similar lack of change.

I would have expected this transformation to be arch-agnostic given that it's at the IR level, so it's interesting to see such big differences.

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


More information about the llvm-commits mailing list