From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8991 invoked by alias); 30 May 2012 10:35:05 -0000 Received: (qmail 8897 invoked by uid 22791); 30 May 2012 10:35:04 -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; Wed, 30 May 2012 10:34:51 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/53501] [4.5/4.6/4.7/4.8 Regression] scev introduces signed overflow Date: Wed, 30 May 2012 10:55: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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.5.4 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: 2012-05/txt/msg02836.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53501 --- Comment #3 from Richard Guenther 2012-05-30 10:34:50 UTC --- It's my very best friend extract_muldiv that transforms (int)((unsigned int) n.0_26 + 4294967295) * 2 to (int)(((unsigned int) n.0_26 + 2147483647) * 2) It is the folding of (int) (((unsigned int) n.0_26 + 2147483647) * 2) + 2 which is wrong and done by fold_plusminus_mult_expr. Patch: Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 188004) +++ gcc/fold-const.c (working copy) @@ -10045,12 +10045,12 @@ fold_binary_loc (location_t loc, /* Handle (A1 * C1) + (A2 * C2) with A1, A2 or C1, C2 being the same or one. Make sure type is not saturating. fold_plusminus_mult_expr will re-associate. */ - if ((TREE_CODE (arg0) == MULT_EXPR - || TREE_CODE (arg1) == MULT_EXPR) + if ((TREE_CODE (op0) == MULT_EXPR + || TREE_CODE (op1) == MULT_EXPR) && !TYPE_SATURATING (type) && (!FLOAT_TYPE_P (type) || flag_associative_math)) { - tree tem = fold_plusminus_mult_expr (loc, code, type, arg0, arg1); + tree tem = fold_plusminus_mult_expr (loc, code, type, op0, op1); if (tem) return tem; } that will leave the expression unsimplified.