Created attachment 50819 [details] reduced testcase (from openssl sources) Output: $ x86_64-pc-linux-gnu-gcc -Os -fno-dce -fno-defer-pop -fno-forward-propagate -flive-range-shrinkage -fno-rerun-cse-after-loop -mno-push-args testcase.c $ ./a.out Aborted bn_add_words() is called with r == NULL $ x86_64-pc-linux-gnu-gcc -v Using built-in specs. COLLECT_GCC=/repo/gcc-trunk/binary-latest/bin/x86_64-pc-linux-gnu-gcc COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r12-815-20210516001637-g1ba3f0ef546-checking-yes-rtl-df-extra-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++ --enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra --with-cloog --with-ppl --with-isl --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld --with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch --prefix=/repo/gcc-trunk//binary-trunk-r12-815-20210516001637-g1ba3f0ef546-checking-yes-rtl-df-extra-amd64 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.0.0 20210516 (experimental) (GCC)
Confirmed, started with r10-7515-g2c0fa3ecf70d199a.
Looks to be fixed on the trunk.
There seems to be some IR difference on the gimple level which might be making this latent. In GCC 11.2.0 we have (bn_add_words) : _2 = n_3 & -4; ... if (_2 != 0) While on the trunk we have: _14 = (unsigned int) n_3; if (_14 > 3) This does look like a valid transformation knowing that n is subtracted by 4.
(In reply to Andrew Pinski from comment #3) > There seems to be some IR difference on the gimple level which might be > making this latent. But that is not where the problem is located really as far as I can tell, the assembly for bn_mul_recursive is different too (and it looks like the difference in the assembly for bn_add_words is only different in the comparison and nothing else [no other code changes]).
It's fixed on master with r12-5944-ga7acb6dca941db2b. Which is a revision that changes LRA costs.
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
GCC 10 branch is being closed.
Fixed in gcc-12 and newer. Adjusting regression markers.