From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22674 invoked by alias); 11 Aug 2011 12:14:20 -0000 Received: (qmail 22663 invoked by uid 22791); 11 Aug 2011 12:14:17 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CL,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; Thu, 11 Aug 2011 12:14:02 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/50037] Unroll factor exceeds max trip count Date: Thu, 11 Aug 2011 12:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: 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: --- X-Bugzilla-Changed-Fields: 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: 2011-08/txt/msg01084.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50037 --- Comment #7 from Richard Guenther 2011-08-11 12:12:56 UTC --- The following patch makes us handle the canonical testcase on the tree level, but not yet the original testcase (because of the * 2). We should really preserve value-range information from VRP. Index: gcc/tree-ssa-loop-niter.c =================================================================== --- gcc/tree-ssa-loop-niter.c (revision 177649) +++ gcc/tree-ssa-loop-niter.c (working copy) @@ -126,6 +126,32 @@ determine_value_range (tree type, tree v return; } + /* Check if we can determine a value-range from VARs definition. + ??? We should simply preserve VRP information. */ + if (TREE_CODE (var) == SSA_NAME) + { + gimple def_stmt = SSA_NAME_DEF_STMT (var); + if (is_gimple_assign (def_stmt) + && gimple_assign_rhs_code (def_stmt) == BIT_AND_EXPR) + { + tree rhs2 = gimple_assign_rhs2 (def_stmt); + if (TREE_CODE (rhs2) == INTEGER_CST + && tree_int_cst_sgn (rhs2) > 0) + { + double_int maxdi; + if (TREE_INT_CST_HIGH (rhs2) == 0) + maxdi = double_int_mask (HOST_BITS_PER_WIDE_INT + - clz_hwi (TREE_INT_CST_LOW (rhs2))); + else + maxdi = double_int_mask (HOST_BITS_PER_DOUBLE_INT + - clz_hwi (TREE_INT_CST_LOW (rhs2))); + mpz_set_si (min, 0); + mpz_set_double_int (max, maxdi, true); + return; + } + } + } + /* If the computation may wrap, we know nothing about the value, except for the range of the type. */ get_type_static_bounds (type, min, max);