public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/109317] New: -Os generates bigger code than -O2 on 32-bit ARM
@ 2023-03-28 16:27 pali at kernel dot org
  2023-03-29  7:04 ` [Bug target/109317] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pali at kernel dot org @ 2023-03-28 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109317
           Summary: -Os generates bigger code than -O2 on 32-bit ARM
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pali at kernel dot org
  Target Milestone: ---
            Target: arm-linux-gnueabi

Simple loops like the one in the example below are better optimized for size on
32-bit ARM with -O2 option than -Os option.


$ cat test-arm.c
char *test1(char *ptr) {
  while (*ptr != '\0' || *(ptr+1) != '\0') ptr++;
  ptr++;
  return ptr;
}



$ arm-linux-gnueabi-gcc -O2 -c test-arm.c && arm-linux-gnueabi-objdump -d
test-arm.o

test-arm.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <test1>:
   0:   e5d02000        ldrb    r2, [r0]
   4:   e2800001        add     r0, r0, #1
   8:   e3520000        cmp     r2, #0
   c:   1afffffb        bne     0 <test1>
  10:   e5d02000        ldrb    r2, [r0]
  14:   e3520000        cmp     r2, #0
  18:   1afffff8        bne     0 <test1>
  1c:   e12fff1e        bx      lr



$ arm-linux-gnueabi-gcc -Os -c test-arm.c && arm-linux-gnueabi-objdump -d
test-arm.o

test-arm.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <test1>:
   0:   e1a03000        mov     r3, r0
   4:   e5d32000        ldrb    r2, [r3]
   8:   e2800001        add     r0, r0, #1
   c:   e3520000        cmp     r2, #0
  10:   1afffffa        bne     0 <test1>
  14:   e5d02000        ldrb    r2, [r0]
  18:   e3520000        cmp     r2, #0
  1c:   1afffff7        bne     0 <test1>
  20:   e12fff1e        bx      lr



$ arm-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/12/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Debian 12.2.0-14'
--with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-12 --enable-shared
--enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm
--disable-libquadmath --disable-libquadmath-support --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--without-target-system-zlib --enable-multiarch --disable-sjlj-exceptions
--with-arch=armv5te --with-float=soft --disable-werror
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=arm-linux-gnueabi --program-prefix=arm-linux-gnueabi-
--includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Debian 12.2.0-14)

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

* [Bug target/109317] -Os generates bigger code than -O2 on 32-bit ARM
  2023-03-28 16:27 [Bug target/109317] New: -Os generates bigger code than -O2 on 32-bit ARM pali at kernel dot org
@ 2023-03-29  7:04 ` rguenth at gcc dot gnu.org
  2023-04-22 20:57 ` pali at kernel dot org
  2024-03-13 21:47 ` pali at kernel dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-03-29  7:04 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization, ra

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Uh, it's a single move ... possibly SSA coalescing or whatnot.

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

* [Bug target/109317] -Os generates bigger code than -O2 on 32-bit ARM
  2023-03-28 16:27 [Bug target/109317] New: -Os generates bigger code than -O2 on 32-bit ARM pali at kernel dot org
  2023-03-29  7:04 ` [Bug target/109317] " rguenth at gcc dot gnu.org
@ 2023-04-22 20:57 ` pali at kernel dot org
  2024-03-13 21:47 ` pali at kernel dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pali at kernel dot org @ 2023-04-22 20:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Pali Rohár <pali at kernel dot org> ---
Any idea what can be done with this?

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

* [Bug target/109317] -Os generates bigger code than -O2 on 32-bit ARM
  2023-03-28 16:27 [Bug target/109317] New: -Os generates bigger code than -O2 on 32-bit ARM pali at kernel dot org
  2023-03-29  7:04 ` [Bug target/109317] " rguenth at gcc dot gnu.org
  2023-04-22 20:57 ` pali at kernel dot org
@ 2024-03-13 21:47 ` pali at kernel dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pali at kernel dot org @ 2024-03-13 21:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Pali Rohár <pali at kernel dot org> ---
Do you need some more input or test data about this issue?

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

end of thread, other threads:[~2024-03-13 21:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 16:27 [Bug target/109317] New: -Os generates bigger code than -O2 on 32-bit ARM pali at kernel dot org
2023-03-29  7:04 ` [Bug target/109317] " rguenth at gcc dot gnu.org
2023-04-22 20:57 ` pali at kernel dot org
2024-03-13 21:47 ` pali at kernel dot 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).