From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 75DE83858C50; Tue, 28 Mar 2023 16:27:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75DE83858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680020831; bh=SKSdcNSTOX6968BEBtWUo5GgWyX7uwK6nS4sKQaoYFM=; h=From:To:Subject:Date:From; b=Kdd7OJgKxxZ0qsm74uK+BYz+XrJ/EtPA7InzN5T4YxQGLjhsmXHHWFqe02lzHaWXq UeQc+YdVPbK11Mci9xPMj/r3B8dO9FM2EDkZoRbLG37lL6DH2ABvhJn+kyu++vD49R nZvt2iaOiyu5PoDh4bfsjTVNE13vki93deqKaykU= From: "pali at kernel dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/109317] New: -Os generates bigger code than -O2 on 32-bit ARM Date: Tue, 28 Mar 2023 16:27:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pali at kernel dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcctarget Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109317 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 siz= e on 32-bit ARM with -O2 option than -Os option. $ cat test-arm.c char *test1(char *ptr) { while (*ptr !=3D '\0' || *(ptr+1) !=3D '\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 : 0: e5d02000 ldrb r2, [r0] 4: e2800001 add r0, r0, #1 8: e3520000 cmp r2, #0 c: 1afffffb bne 0 10: e5d02000 ldrb r2, [r0] 14: e3520000 cmp r2, #0 18: 1afffff8 bne 0 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 : 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 14: e5d02000 ldrb r2, [r0] 18: e3520000 cmp r2, #0 1c: 1afffff7 bne 0 20: e12fff1e bx lr $ arm-linux-gnueabi-gcc -v Using built-in specs. COLLECT_GCC=3Darm-linux-gnueabi-gcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc-cross/arm-linux-gnueabi/12/lto-wrapper Target: arm-linux-gnueabi Configured with: ../src/configure -v --with-pkgversion=3D'Debian 12.2.0-14' --with-bugurl=3Dfile:///usr/share/doc/gcc-12/README.Bugs --enable-languages=3Dc,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=3D/usr --with-gcc-major-version-only --program-suffix=3D-12 --enable-shared --enable-linker-build-id --libexecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --libdir=3D/usr/lib --enable-nls --with-sysroot=3D/ --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dy= es --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-object --disable-lib= itm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=3Drelea= se --without-target-system-zlib --enable-multiarch --disable-sjlj-exceptions --with-arch=3Darmv5te --with-float=3Dsoft --disable-werror --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linu= x-gnu --target=3Darm-linux-gnueabi --program-prefix=3Darm-linux-gnueabi- --includedir=3D/usr/arm-linux-gnueabi/include Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (Debian 12.2.0-14)=