https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109019
Bug ID: 109019 Summary: Failure to optimize b + c -1 Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tkoenig at gcc dot gnu.org Target Milestone: --- Looks like a general RTL issue, I see this on POWER, RV64 and ARM64 (the latter two on godbolt). [tkoenig@gcc135 ~]$ cat c.c long foo (long b, long c) { return b + c - 1; } [tkoenig@gcc135 ~]$ gcc -O3 -S c.c [tkoenig@gcc135 ~]$ cat c.s .file "c.c" .machine power8 .abiversion 2 .section ".text" .align 2 .p2align 4,,15 .globl foo .type foo, @function foo: .LFB0: .cfi_startproc add 3,3,4 addi 3,3,-1 blr .long 0 .byte 0,0,0,0,0,0,0,0 .cfi_endproc .LFE0: .size foo,.-foo .ident "GCC: (GNU) 13.0.1 20230215 (experimental)" .section .note.GNU-stack,"",@progbits This should be addi 3,4,-1 ret