public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/109019] New: Failure to optimize b + c -1
@ 2023-03-03 23:49 tkoenig at gcc dot gnu.org
  2023-03-03 23:57 ` [Bug rtl-optimization/109019] " jakub at gcc dot gnu.org
  2023-03-04  0:01 ` tkoenig at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2023-03-03 23:49 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug rtl-optimization/109019] Failure to optimize b + c -1
  2023-03-03 23:49 [Bug rtl-optimization/109019] New: Failure to optimize b + c -1 tkoenig at gcc dot gnu.org
@ 2023-03-03 23:57 ` jakub at gcc dot gnu.org
  2023-03-04  0:01 ` tkoenig at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-03 23:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109019

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
How could it?
        addi    3,4,-1
        blr
would be return c - 1; rather than return b + c - 1;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug rtl-optimization/109019] Failure to optimize b + c -1
  2023-03-03 23:49 [Bug rtl-optimization/109019] New: Failure to optimize b + c -1 tkoenig at gcc dot gnu.org
  2023-03-03 23:57 ` [Bug rtl-optimization/109019] " jakub at gcc dot gnu.org
@ 2023-03-04  0:01 ` tkoenig at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2023-03-04  0:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109019

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Urgh,too late in the evening, I guess. Sorry for the noise.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-04  0:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 23:49 [Bug rtl-optimization/109019] New: Failure to optimize b + c -1 tkoenig at gcc dot gnu.org
2023-03-03 23:57 ` [Bug rtl-optimization/109019] " jakub at gcc dot gnu.org
2023-03-04  0:01 ` tkoenig at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).