Bug 100623 - [11 Regression] wrong code with -Os -fno-dce -fno-defer-pop -fno-forward-propagate -flive-range-shrinkage -fno-rerun-cse-after-loop -mno-push-args since r10-7515-g2c0fa3ecf70d199a
Summary: [11 Regression] wrong code with -Os -fno-dce -fno-defer-pop -fno-forward-prop...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 12.0
: P2 normal
Target Milestone: 11.5
Assignee: Not yet assigned to anyone
URL:
Keywords: ra, wrong-code
Depends on:
Blocks:
 
Reported: 2021-05-16 14:46 UTC by Zdenek Sojka
Modified: 2024-03-11 03:39 UTC (History)
3 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail: 10.3.1, 11.1.1, 11.2.0, 12.0
Last reconfirmed: 2021-05-17 00:00:00


Attachments
reduced testcase (from openssl sources) (325 bytes, text/plain)
2021-05-16 14:46 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2021-05-16 14:46:35 UTC
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)
Comment 1 Martin Liška 2021-05-17 08:05:19 UTC
Confirmed, started with r10-7515-g2c0fa3ecf70d199a.
Comment 2 Andrew Pinski 2022-01-29 23:48:46 UTC
Looks to be fixed on the trunk.
Comment 3 Andrew Pinski 2022-01-29 23:55:14 UTC
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.
Comment 4 Andrew Pinski 2022-01-29 23:59:33 UTC
(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]).
Comment 5 Martin Liška 2022-01-31 14:38:27 UTC
It's fixed on master with r12-5944-ga7acb6dca941db2b. Which is a revision that changes LRA costs.
Comment 6 Jakub Jelinek 2022-06-28 10:45:03 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 7 Richard Biener 2023-07-07 10:39:58 UTC
GCC 10 branch is being closed.
Comment 8 Jeffrey A. Law 2024-03-11 03:39:11 UTC
Fixed in gcc-12 and newer.  Adjusting regression markers.