From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1981C3858C2C; Thu, 9 Sep 2021 12:51:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1981C3858C2C From: "dumoulin.thibaut at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/101981] GCC10 produces bigger asm for simple switch than GCC7 - cortexM4 since r8-2701-g9dc3d6a96167b4c8 Date: Thu, 09 Sep 2021 12:51:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.3.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: dumoulin.thibaut at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Sep 2021 12:51:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101981 --- Comment #7 from Thibaut M. --- There are other regressions (in term of code size) but not sure if this is = the same. For example, this code: ```C #include void big_switch(int a) { switch (a) { default: printf("default a(%d)\n", a); case 0x1: case 0x2: // case 0x3: // case 0x4: case 0x5: case 0x6: // case 0x7: // case 0x8: // case 0x9: case 0xA: case 0xD: case 0xE: case 0xF: // case 0x10: case 0x11: case 0x12: // case 0x13: // case 0x14: case 0x15: case 0x17: case 0x18: case 0x19: case 0x1A: // case 0x1B: case 0x1C: case 0x1D: { printf("a(%d)\n", a); } break; } } int main(void) { big_switch(2); return 0; } ``` with compile parameters `arm-none-eabi-gcc -Os -mcpu=3Dcortex-m4 ./switch.c` the asm is lighter with GCC7.3.1 than with GCC10.3.1. While GCC7.3.1 (20 lines) ```asm 00008134 : cmp r0, #29 push {r4, lr} mov r4, r0 bhi.n 8146 movs r2, #1 ldr r3, [pc, #28] ; (815c ) lsls r2, r0 ands r3, r2 cbnz r3, 814e mov r1, r4 ldr r0, [pc, #20] ; (8160 ) bl 8264 mov r1, r4 ldr r0, [pc, #16] ; (8164 ) ldmia.w sp!, {r4, lr} b.w 8264 nop .word 0x37a6e466 .word 0x0000f5f8 .word 0x0000f600 ``` GCC10.3.1 (24 lines) ```asm 0000813c : subs r3, r0, #1 push {r4, lr} mov r4, r0 cmp r3, #28 bhi.n 8168 tbb [pc, r3] .short 0x1313 .word 0x13130f0f .word 0x130f0f0f .word 0x13130f0f .word 0x13130f13 .word 0x0f130f0f .word 0x13131313 .short 0x130f .byte 0x13 .byte 0x00 mov r1, r0 ldr r0, [pc, #16] ; (817c ) bl 828c mov r1, r4 ldr r0, [pc, #8] ; (817c ) ldmia.w sp!, {r4, lr} b.w 828c .word 0x0001011c ``` Not a big difference in term of instructions is this case but as much as the switch increases, the difference becomes huge (in my case it switched from = 75 to 94 lines) Code size increases of about 10%. @Martin, do you know if this is linked?=