From patchwork Tue Aug 31 20:13:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 63315 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 434F5B7146 for ; Wed, 1 Sep 2010 06:14:14 +1000 (EST) Received: (qmail 10856 invoked by alias); 31 Aug 2010 20:14:10 -0000 Received: (qmail 10844 invoked by uid 22791); 31 Aug 2010 20:14:08 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 Aug 2010 20:14:02 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 829DCCB0245; Tue, 31 Aug 2010 22:14:00 +0200 (CEST) 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 rUFeZPb5kAq4; Tue, 31 Aug 2010 22:14:00 +0200 (CEST) Received: from new-host-2.home (ADijon-552-1-118-151.w92-148.abo.wanadoo.fr [92.148.61.151]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 5B08CCB023F; Tue, 31 Aug 2010 22:14:00 +0200 (CEST) From: Eric Botcazou To: Richard Guenther Subject: [patch] Fix pessimization with volatile objects Date: Tue, 31 Aug 2010 22:13:40 +0200 User-Agent: KMail/1.9.9 Cc: gcc-patches@gcc.gnu.org MIME-Version: 1.0 Message-Id: <201008312213.41067.ebotcazou@adacore.com> 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 Hi Richard, last January you applied a fix for an issue related to volatile objects: 2010-01-31 Richard Guenther PR middle-end/42898 * gimplify.c (gimplify_init_constructor): For volatile LHS initialize a temporary. on all branches. Unfortunately this pessimizes a relatively common case in Ada, namely the assignment from a constructor with only one element. May I apply the attached patch on all branches as well (after testing)? 2010-08-31 Eric Botcazou * gimplify.c (gimplify_init_constructor): Do not create a temporary for a volatile LHS if the constructor has only one element. Index: gimplify.c =================================================================== --- gimplify.c (revision 163660) +++ gimplify.c (working copy) @@ -3824,11 +3824,12 @@ gimplify_init_constructor (tree *expr_p, } } - /* If the target is volatile and we have non-zero elements - initialize the target from a temporary. */ + /* If the target is volatile, we have non-zero elements and more than + one field to assign, initialize the target from a temporary. */ if (TREE_THIS_VOLATILE (object) && !TREE_ADDRESSABLE (type) - && num_nonzero_elements > 0) + && num_nonzero_elements > 0 + && VEC_length (constructor_elt, elts) > 1) { tree temp = create_tmp_var (TYPE_MAIN_VARIANT (type), NULL); TREE_OPERAND (*expr_p, 0) = temp;