From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18919 invoked by alias); 10 Jan 2013 11:26:55 -0000 Received: (qmail 18217 invoked by uid 48); 10 Jan 2013 11:26:15 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/32306] [4.6/4.7/4.8 Regression] redundant && || not eliminated Date: Thu, 10 Jan 2013 11:26:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.4 X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2013-01/txt/msg00926.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32306 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #23 from Jakub Jelinek 2013-01-10 11:26:09 UTC --- It generally depends on the branch cost, e.g. out of #c19 testcase on x86_64 we generate: D.1729 = b1 != 0; D.1730 = b2 != 0; D.1731 = D.1729 & D.1730; if (D.1731 != 0) goto ; else goto ; : D.1733 = b3 != 0; D.1734 = b4 != 0; D.1735 = D.1733 & D.1734; if (D.1735 != 0) goto ; else goto ; : etc., but on other targets it could have just one comparison per conditional jump, or on the other side 4. While the tests don't have side-effects, turning too many &&s into &s wouldn't result in very good code, though of course would make it easier to perform some optimizations. Anyway, you can write it in the source as a series of ifs: array[0] = 1; if (!b1) array[0] = 0; else if (!b2) array[0] = 0; else if (!b3) array[0] = 0; ... and we wouldn't be able to optimize it anyway.