From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30588 invoked by alias); 7 Oct 2015 06:32:48 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 30557 invoked by uid 48); 7 Oct 2015 06:32:44 -0000 From: "marccelani at fb dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/67879] New: unnecessary jump in ternary Date: Wed, 07 Oct 2015 06:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: marccelani at fb dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg00481.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67879 Bug ID: 67879 Summary: unnecessary jump in ternary Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: marccelani at fb dot com Target Milestone: --- The following functions f and f2 should compile the same, but f includes a jump whereas f2 properly avoids the jump and adds the result of the comparison. int f(int a, int b, int* c) { bool x = a < b; return x ? *c : *c + 1; } int f2(int a, int b, int* c) { bool x = a < b; return *c + (x ? 0 : 1); } https://goo.gl/OFhXTp