public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/103710] New: Missed optimization: common bit prefix/suffixes of multiple values
@ 2021-12-14 15:33 jengelh at inai dot de
  2021-12-14 15:37 ` [Bug rtl-optimization/103710] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jengelh at inai dot de @ 2021-12-14 15:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103710

            Bug ID: 103710
           Summary: Missed optimization: common bit prefix/suffixes of
                    multiple values
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jengelh at inai dot de
  Target Milestone: ---

Environment:
» ./xgcc -v ...
Reading specs from /home/jengelh/repos/gcc/host-x86_64-pc-linux-gnu/gcc/specs
COLLECT_GCC=./xgcc
Target: x86_64-pc-linux-gnu
Configured with: ./configure --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211214 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-B'
'/home/jengelh/repos/gcc/host-x86_64-pc-linux-gnu/gcc' '-D' 'noexcept=' '-c'
'-O2' '-mtune=generic' '-march=x86-64'
GNU C17 (GCC) version 12.0.0 20211214 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 11.2.1 20211124 [revision
7510c23c1ec53aa4a62705f0384079661342ff7b], GMP version 6.2.1, MPFR version
4.1.0-p7, MPC version 1.2.1, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096


Input: attachment #0
Observed output:

$ ./xgcc -B. -x c++ -c -O2 t.cpp && readelf -a t.o | grep fct
     3: 0000000000000000    54 FUNC    GLOBAL DEFAULT    1 _Z4fct0j
     4: 0000000000000040    54 FUNC    GLOBAL DEFAULT    1 _Z4fct4j
     5: 0000000000000080    54 FUNC    GLOBAL DEFAULT    1 _Z4fct8j
     6: 00000000000000c0    54 FUNC    GLOBAL DEFAULT    1 _Z5fct12j
     7: 0000000000000100    54 FUNC    GLOBAL DEFAULT    1 _Z5fct16j
     8: 0000000000000140    54 FUNC    GLOBAL DEFAULT    1 _Z5fct20j
     9: 0000000000000180    38 FUNC    GLOBAL DEFAULT    1 _Z5fct24j
    10: 00000000000001b0    32 FUNC    GLOBAL DEFAULT    1 _Z5fct25j
    11: 00000000000001d0    35 FUNC    GLOBAL DEFAULT    1 _Z6fctmaxj

Desired output:

Provided I made no mistake in the equivalency of all fct functions, the fct
functions should, preferably, all compile to the same machine code.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/103710] Missed optimization: common bit prefix/suffixes of multiple values
  2021-12-14 15:33 [Bug rtl-optimization/103710] New: Missed optimization: common bit prefix/suffixes of multiple values jengelh at inai dot de
@ 2021-12-14 15:37 ` pinskia at gcc dot gnu.org
  2021-12-14 16:10 ` jengelh at inai dot de
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-14 15:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103710

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Attachment didn't go through?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/103710] Missed optimization: common bit prefix/suffixes of multiple values
  2021-12-14 15:33 [Bug rtl-optimization/103710] New: Missed optimization: common bit prefix/suffixes of multiple values jengelh at inai dot de
  2021-12-14 15:37 ` [Bug rtl-optimization/103710] " pinskia at gcc dot gnu.org
@ 2021-12-14 16:10 ` jengelh at inai dot de
  2021-12-14 16:14 ` [Bug tree-optimization/103710] " pinskia at gcc dot gnu.org
  2021-12-14 16:20 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jengelh at inai dot de @ 2021-12-14 16:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103710

--- Comment #2 from Jan Engelhardt <jengelh at inai dot de> ---
Created attachment 52001
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52001&action=edit
testcase

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/103710] Missed optimization: common bit prefix/suffixes of multiple values
  2021-12-14 15:33 [Bug rtl-optimization/103710] New: Missed optimization: common bit prefix/suffixes of multiple values jengelh at inai dot de
  2021-12-14 15:37 ` [Bug rtl-optimization/103710] " pinskia at gcc dot gnu.org
  2021-12-14 16:10 ` jengelh at inai dot de
@ 2021-12-14 16:14 ` pinskia at gcc dot gnu.org
  2021-12-14 16:20 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-14 16:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103710

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|rtl-optimization            |tree-optimization
           Severity|normal                      |enhancement

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/103710] Missed optimization: common bit prefix/suffixes of multiple values
  2021-12-14 15:33 [Bug rtl-optimization/103710] New: Missed optimization: common bit prefix/suffixes of multiple values jengelh at inai dot de
                   ` (2 preceding siblings ...)
  2021-12-14 16:14 ` [Bug tree-optimization/103710] " pinskia at gcc dot gnu.org
@ 2021-12-14 16:20 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-14 16:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103710

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-12-14
     Ever confirmed|0                           |1

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is another function which should produce the same code:

unsigned char fctn1(unsigned int z) noexcept
{
    switch(z)
    {
        case 0x0e000000 ... 0x0fffffff:
          return 1;
        case 0x60000000 ... 0x67ffffff:
          return 1;
        case 0x7c000000 ... 0x7fffffff:
          return 1;
    }
  return 0;
}

I think GCC produces non-optimial code for all cases even.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-14 16:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 15:33 [Bug rtl-optimization/103710] New: Missed optimization: common bit prefix/suffixes of multiple values jengelh at inai dot de
2021-12-14 15:37 ` [Bug rtl-optimization/103710] " pinskia at gcc dot gnu.org
2021-12-14 16:10 ` jengelh at inai dot de
2021-12-14 16:14 ` [Bug tree-optimization/103710] " pinskia at gcc dot gnu.org
2021-12-14 16:20 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).