public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/95014] New: gcc fails to merge two identical returns
@ 2020-05-08 18:40 rafael at espindo dot la
  2021-04-30 17:58 ` [Bug middle-end/95014] " vanyacpp at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rafael at espindo dot la @ 2020-05-08 18:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95014
           Summary: gcc fails to merge two identical returns
           Product: gcc
           Version: 10.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rafael at espindo dot la
  Target Milestone: ---

Given

#include <new>
union any {
    any(any&& x) noexcept {
        if (x.st < 4) {
            st = x.st;
            x.st = 0;
        } else {
            ex = x.ex;
            x.ex = nullptr;
        }
    }
    long st;
    void* ex;
};
void f(any* a, any* b) {
    new (a) any(std::move(*b));
}

gcc produces

        movq    (%rsi), %rax
        movq    %rax, (%rdi)
        movq    $0, (%rsi)
        cmpq    $3, %rax
        jg      .L2
        ret
.L2:
        ret


clang produces

        movq    (%rsi), %rax
        cmpq    $3, %rax
        movq    %rax, (%rdi)
        movq    $0, (%rsi)
        retq

So clang has a redundant cmpq and gcc has the cmpq and two identical branch
destinations.

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

end of thread, other threads:[~2023-08-08  6:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08 18:40 [Bug middle-end/95014] New: gcc fails to merge two identical returns rafael at espindo dot la
2021-04-30 17:58 ` [Bug middle-end/95014] " vanyacpp at gmail dot com
2021-08-01 18:28 ` pinskia at gcc dot gnu.org
2023-08-08  6:23 ` pinskia 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).