From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2901 invoked by alias); 19 Jun 2012 13:18:52 -0000 Received: (qmail 2838 invoked by uid 22791); 19 Jun 2012 13:18:49 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Jun 2012 13:18:35 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/53676] [4.7/4.8 regression] empty loop is not always removed now Date: Tue, 19 Jun 2012 13:18: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-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: 4.7.2 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: 2012-06/txt/msg01260.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53676 Richard Guenther changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #5 from Richard Guenther 2012-06-19 13:18:19 UTC --- First of all confirmed. We rely on SCCP to compute the overall loop effect which does not happen anymore. The loops are different - 4.6 has : # result_81 = PHI # n_78 = PHI result.7_42 = (unsigned char) result_81; D.7248_43 = result.7_42 + 2; result_44 = (signed char) D.7248_43; n_46 = n_78 + 1; if (n_46 != 8000) goto ; else goto ; but with 4.7 we see : # result_76 = PHI # n_77 = PHI D.7583_48 = (int) result_76; D.7582_49 = D.7583_48 + 2; result_50 = (signed char) D.7582_49; n_52 = n_77 + 1; if (n_52 != 8000) goto ; else goto ; thus 4.6 performed the premature shortening optimization that 4.7 no longer performs. Testcase that nobody handles because it has the operation explicitely in int: int main() { int i; signed char result = 0; for (i = 0; i != 8000; ++i) { int tem = result; tem = tem + 2; result = tem; } if (__builtin_abs ((int)(signed char)((unsigned char ) result + 128)) != 0) __builtin_abort (); return 0; } Proper action could be to implement that shortening inside forwprop or to teach the trick to SCEV analysis.