From patchwork Wed Nov 7 22:21:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 197734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D0E2A2C0097 for ; Thu, 8 Nov 2012 09:29:24 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352932165; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=79d+RY/nuswgd37DawiLn4Icn6U=; b=R4dmzidw2Vdi8VJ MzcsdUudc9q6hUUWNud8YU5Iop1du6NHt8SUNf7cl1squfqtheIx52WaSABCMr+l ijdPld9Hki2HOoU3c3qy0618yqv0I5qGldYKyLzLx7lzwnpyiN5c0QtDJJUOBaQu hLBK5e9i8fVwJMY2MeyxNECMqlh4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=PipQEXroBME7Uv7/ojVjNOxUK4ZspWeqOdNPX4urxMs5/Pd9Tdv+2GHnY19Y6I lwjfrSOZNghz+HvR+ZzseRoK+Tqd/3Tap2egka+xNcr8i93MMdFLmmmT22nF5wFS u5y0WEI5LoPwtHrW1eewXVGjB7b0LEtEm4n8+p2XeJ8+Q=; Received: (qmail 3782 invoked by alias); 7 Nov 2012 22:29:20 -0000 Received: (qmail 3774 invoked by uid 22791); 7 Nov 2012 22:29:20 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Nov 2012 22:29:16 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 33AEFCB07CA for ; Wed, 7 Nov 2012 23:29:17 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WVUXHhzGRxRR for ; Wed, 7 Nov 2012 23:29:17 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id E93E2CB07AA for ; Wed, 7 Nov 2012 23:29:16 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR middle-end/55219 Date: Wed, 07 Nov 2012 23:21:59 +0100 Message-ID: <5336214.jMX7Aekqkv@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.16-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This is a regression present on the mainline and 4.7 branch. For expressions of the form: h = (g ? c : g ? f : g ? e : g ? i : g ? f : g ? e : g ? d : x) + (a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? j : a ? : 0 ? : a ? : a ? : a ? : a ? : a ? : a ? k : a ? : x); there is a memory explosion in the folder: fold_binary_op_with_conditional_arg is distributing the + inside the conditional expressions at each level recursively. The transformation was originally applied only if the argument was TREE_CONSTANT, but during 4.7 development I extended it to more general arguments to help Ada. Fixed by disabling recursion entirely, as it was originally. Bootstrapped/regtested on x86_64-suse-linux, applied on mainline and 4.7 branch as obvious. 2012-11-07 Eric Botcazou PR middle-end/55219 * fold-const.c (fold_binary_op_with_conditional_arg): Do not fold if the argument is itself a conditional expression. 2012-11-07 Eric Botcazou * gcc.c-torture/compile/20121107-1.c: New test. Index: fold-const.c =================================================================== --- fold-const.c (revision 193280) +++ fold-const.c (working copy) @@ -5987,10 +5987,11 @@ fold_binary_op_with_conditional_arg (loc cond_code = VEC_COND_EXPR; /* This transformation is only worthwhile if we don't have to wrap ARG - in a SAVE_EXPR and the operation can be simplified on at least one - of the branches once its pushed inside the COND_EXPR. */ + in a SAVE_EXPR and the operation can be simplified without recursing + on at least one of the branches once its pushed inside the COND_EXPR. */ if (!TREE_CONSTANT (arg) && (TREE_SIDE_EFFECTS (arg) + || TREE_CODE (arg) == COND_EXPR || TREE_CODE (arg) == VEC_COND_EXPR || TREE_CONSTANT (true_value) || TREE_CONSTANT (false_value))) return NULL_TREE;