From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 903F13858D20; Wed, 31 May 2023 18:12:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 903F13858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685556744; bh=vPtJdZ9k9r+1qm2fl3jMkzHXXQ/aQBZ4fHX8Po/6POs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cvmWPp5t9Gg5rEOHNHPq8CeaKRExP6qpb1afa1lOhxivHXDhGAT8LV6kLNTYRn9X/ IoNBFgxTlaEDLVh35WuP+JWIv9dPb+LVyuCFffVMpvQmU9F0vmay+1/FWryNs8RUjo smf1qoFSeGfQAgGjtgDYJkuSts7i7ZGnXZPLh20E= From: "aldot at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/110052] useless local variable not optimized away Date: Wed, 31 May 2023 18:12:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: aldot at gcc dot gnu.org X-Bugzilla-Status: WAITING 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110052 --- Comment #3 from Bernhard Reutner-Fischer --- Note that in this particular case myrealloc() is static, maybe i should have omitted the noipa attribute for it was only meant to simplify analysis and there is no such attribute in the original code. Furthermore, i would have hoped that given the placement of the definition = of myrealloc() before the typedef foo_t, it should be unlikely that the usage = of *foo would invalidate such an optimisation _in this particular case_. While= the original code unfortunately does not mark *foo as restrict, adding restrict would hopefully make it clear that myrealloc() has no business in comparing foo's struct members, i'd hope? When i drop the noipa attribute in the v1 testcase to make it similar to the motivating case, i get: 9: 0000000000000000 44 FUNC GLOBAL DEFAULT 4 bloat 12: 0000000000000000 38 FUNC GLOBAL DEFAULT 6 ok 0000000000000000 : 0: 53 push %rbx 1: 48 83 7f 08 00 cmpq $0x0,0x8(%rdi) 6: 48 89 fb mov %rdi,%rbx 9: 8b 47 14 mov 0x14(%rdi),%eax c: 75 19 jne 27 e: bf d0 01 00 00 mov $0x1d0,%edi 13: e8 00 00 00 00 callq 18 18: 48 85 c0 test %rax,%rax 1b: 75 05 jne 22 1d: e8 00 00 00 00 callq 22 22: b8 d0 01 00 00 mov $0x1d0,%eax 27: 89 43 14 mov %eax,0x14(%rbx) 2a: 5b pop %rbx 2b: c3 retq=20=20=20 Disassembly of section .text.ok: 0000000000000000 : 0: 48 83 7f 08 00 cmpq $0x0,0x8(%rdi) 5: 75 1e jne 25 7: 52 push %rdx 8: c7 47 14 d0 01 00 00 movl $0x1d0,0x14(%rdi) f: bf d0 01 00 00 mov $0x1d0,%edi 14: e8 00 00 00 00 callq 19 19: 48 85 c0 test %rax,%rax 1c: 75 05 jne 23 1e: e8 00 00 00 00 callq 23 23: 58 pop %rax 24: c3 retq=20=20=20 25: c3 retq=