https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110052
--- Comment #4 from Bernhard Reutner-Fischer <aldot at gcc dot gnu.org> --- (In reply to Bernhard Reutner-Fischer from comment #3) > 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: Correction: When i replace noipa with noinline,noclone (and drop -ffunction-sections -fdata-sections to improve readability), i get: 10: 0000000000000030 52 FUNC GLOBAL DEFAULT 1 bloat 10: 0000000000000030 21 FUNC GLOBAL DEFAULT 1 ok 0000000000000030 <bloat>: 30: 53 push %rbx 31: 48 89 fb mov %rdi,%rbx 34: 48 83 ec 10 sub $0x10,%rsp 38: 8b 47 14 mov 0x14(%rdi),%eax 3b: 48 83 7f 08 00 cmpq $0x0,0x8(%rdi) 40: 89 44 24 0c mov %eax,0xc(%rsp) 44: 75 11 jne 57 <bloat+0x27> 46: 48 8d 54 24 0c lea 0xc(%rsp),%rdx 4b: be 00 01 00 00 mov $0x100,%esi 50: 31 ff xor %edi,%edi 52: e8 a9 ff ff ff callq 0 <myrealloc> 57: 8b 44 24 0c mov 0xc(%rsp),%eax 5b: 89 43 14 mov %eax,0x14(%rbx) 5e: 48 83 c4 10 add $0x10,%rsp 62: 5b pop %rbx 63: c3 retq 0000000000000030 <ok>: 30: 48 83 7f 08 00 cmpq $0x0,0x8(%rdi) 35: 75 0d jne 44 <ok+0x14> 37: 48 8d 57 14 lea 0x14(%rdi),%rdx 3b: be 00 01 00 00 mov $0x100,%esi 40: 31 ff xor %edi,%edi 42: eb bc jmp 0 <myrealloc> 44: c3 retq