Bug 82454 - Possible future performance regression in x86 for 64-bit constant expansions
Summary: Possible future performance regression in x86 for 64-bit constant expansions
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 8.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2017-10-06 16:57 UTC by Sudakshina Das
Modified: 2023-08-04 00:30 UTC (History)
0 users

See Also:
Host:
Target: x86_64-*-*, i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2023-08-03 00:00:00


Attachments
test1 (235 bytes, text/plain)
2017-10-06 16:57 UTC, Sudakshina Das
Details
test2 (269 bytes, text/plain)
2017-10-06 16:57 UTC, Sudakshina Das
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sudakshina Das 2017-10-06 16:57:08 UTC
Created attachment 42317 [details]
test1

As per the discussions on 

https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00570.html
https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00039.html
https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01736.html

The patch to add a simplification of 1U << (31 - x) for PR 80131, may lead to a performance regression for x86.

I am adding the tests that Jakub mentioned as a runtime performance regression tests.
Comment 1 Sudakshina Das 2017-10-06 16:57:49 UTC
Created attachment 42318 [details]
test2
Comment 2 Richard Biener 2017-10-09 11:54:20 UTC
__INT64_TYPE__ f1 (__INT64_TYPE__ i)
{
  return (((__INT64_TYPE__)1) << 63) >> i;
}

is already an existing missed optimization.
Comment 3 Richard Biener 2017-10-09 11:58:39 UTC
Note the missed-optimization is that any

 (1 << C) >> x

can be instead written as

 1 << C - x

iff we know that C - x > 0.  For C == precision(x)-1 we can infer that
directly from x being mentioned in the shift.
Comment 4 Andrew Pinski 2023-08-04 00:28:14 UTC
Note the -Os regression part was improved via r8-3504-g2891beff1aa8e6 (PR 82339).
Comment 5 Andrew Pinski 2023-08-04 00:30:22 UTC
Actually this looks almost exactly the same as PR 82339 .