From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25152 invoked by alias); 17 Dec 2010 16:17:57 -0000 Received: (qmail 25141 invoked by uid 22791); 17 Dec 2010 16:17:55 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_TM 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; Fri, 17 Dec 2010 16:17:50 +0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/46970] [4.3/4.4/4.5/4.6 Regression] wrong code with -Os -ftree-loop-linear 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: wrong-code X-Bugzilla-Severity: normal 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: 4.3.6 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 Date: Fri, 17 Dec 2010 16:17:00 -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 X-SW-Source: 2010-12/txt/msg02120.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46970 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek 2010-12-17 16:17:39 UTC --- I think the bug is in that gcc_loop_to_lambda_loop doesn't record whether the SSA_NAME compared in the exit condition was the induction var or incremented induction var. E.g. on ltrans-3.c testcase we have : # j_25 = PHI ... j_15 = j_25 + 1; if (N.2_3 > j_15) goto ; else goto ; and thus the exit condition tests the incremented iv (gcc_loop_to_lambda_loop btw. doesn't bother to check whether the def stmt of the rhs of exit condition here actually increments by step, and doesn't bother to check that step fits into int (so I guess step like 0x100000001ULL would cause trouble). It just records lower bound 0, upper bound N.2_3 - 1 here and step 1. But with -Os -ftree-loop-linear on this testcase we have before ltrans: j_12 = j_2 + 1; : # j_2 = PHI <0(7), j_12(3)> if (j_2 < n_5(D)) goto ; else goto ; Here similarly it records lower bound 0, upper bound n_5 - 1 and step 1. But there is an important difference in between the two. In the former case we correctly use gimple_cond_set_condition (exitcond, testtype, newupperbound, ivvarinced); but we use it in the second case too, which is wrong.