public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "SztfG at yandex dot ru" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/68027] New: conditional statement and unnecessary register assignment
Date: Tue, 20 Oct 2015 05:24:00 -0000	[thread overview]
Message-ID: <bug-68027-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 68027
           Summary: conditional statement and unnecessary register
                    assignment
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: SztfG at yandex dot ru
  Target Milestone: ---

C source code:

int a1(int);
int a2(int);
int a3(int);

int test1(int a)
{
  if (a > 100) return a1(a);
  else if (a < 100) return a2(a);
  return a3(a);
}

-----------------------------------

Assembly output:


test1:
.LFB0:
        .cfi_startproc
        cmpl    $100, %edi
        jg      .L5
        jne     .L6
        movl    $100, %edi   # no need to do this, eax is equal $100 at this
point
        jmp     a3
        .p2align 4,,10
        .p2align 3
.L6:
        jmp     a2
        .p2align 4,,10
        .p2align 3
.L5:
        jmp     a1
        .cfi_endproc

-----------------------------------

Tested on http://gcc.godbolt.org/ : gcc versions 4.4.7 - 5.2.0 have this
problem.


             reply	other threads:[~2015-10-20  5:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20  5:24 SztfG at yandex dot ru [this message]
2015-10-20  5:30 ` [Bug middle-end/68027] " SztfG at yandex dot ru
2015-10-20  8:00 ` [Bug tree-optimization/68027] " rguenth at gcc dot gnu.org
2015-10-20  8:28 ` SztfG at yandex dot ru
2015-10-20 17:37 ` SztfG at yandex dot ru
2021-08-10 18:20 ` [Bug tree-optimization/68027] uncprop should work on more than PHI nodes pinskia at gcc dot gnu.org
2021-08-10 18:22 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-68027-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).