From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30342 invoked by alias); 18 Feb 2015 13:57:37 -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 30302 invoked by uid 48); 18 Feb 2015 13:57:34 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/64491] [5 Regression] incorrect warning: loop exit may only be reached after undefined behavior Date: Wed, 18 Feb 2015 13:57:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: 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-02/txt/msg02009.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64491 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ams at gcc dot gnu.org, | |jakub at gcc dot gnu.org --- Comment #7 from Jakub Jelinek --- I think this is just a bogus warning introduced in r217891, the generated code looks ok. Code like: : # f_27 = PHI if (f_27 != 0) goto ; else goto ; : _11 = f_27 + -1; iftmp.0_12 = A[_11]; if (f_27 != 7) goto ; else goto ; : # iftmp.0_28 = PHI _13 = f_27 + 1; iftmp.1_14 = A[_13]; : # iftmp.1_4 = PHI # iftmp.0_29 = PHI _15 = iftmp.0_29 | iftmp.1_4; B[f_27] = _15; f_17 = f_27 + 1; if (f_17 == 8) goto ; else goto ; is transformed by dom1 into an extra early exit from the loop, if f_27 == 7, we jump to a new bb outside of the loop that does: : # iftmp.1_2 = PHI <0(6)> # iftmp.0_3 = PHI _1 = iftmp.0_3 | iftmp.1_2; B[f_27] = _1; f_26 = f_27 + 1; goto ; But indeed dom nor anything else doesn't figure out that the f_17 == 8 exit condition of the loop is then never true, the loop will always exit through the jump to bb 11. Supposedly the warning needs to be limited to the case where the loop has only a single exit, or when the undefined behavior occurs on all loop exits.