From patchwork Wed Sep 18 08:39:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1163839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509178-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Ngv5xlIu"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46YD4m0mnmz9s4Y for ; Wed, 18 Sep 2019 18:42:31 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=kjH0rGMGKg3MGAZxGE6qnR2mQ7aVEfggRvUqejz2bf3jgNx8Kf e9MnGdwISgXgKJQpty5zaBB5Czy2W2U2VWuj5WiiqqYpggES571MvwOb/5LVcmMz NGpY0rXS6TRqnN6VR9FcW7OpriME3uO5IIpSynFfrK5DKeQyIU0juJuqo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=FD04/yXJj7izUaS8s86+WEZTkMM=; b=Ngv5xlIuphGqW6O7BefL kTRTsGLHAMgTniJwqZy0Bv5Cf2hZEkTRj7Mjpz2GXlKsIFQ5dVzHS/JHFBivsEho M7NUT/EPeyR0Aqcp489fZlbwVUlzYezJWfvWAyx9g4kc4E6cp42gVxsI7FmFbWzC KhrJC6j/2G+Ooj4zvcGGx7s= Received: (qmail 101729 invoked by alias); 18 Sep 2019 08:39:57 -0000 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 Received: (qmail 101466 invoked by uid 89); 18 Sep 2019 08:39:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HX-detected-operating-system:fuzzy, substantially, Compute X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Sep 2019 08:39:53 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAVV7-0008FP-CT for gcc-patches@gcc.gnu.org; Wed, 18 Sep 2019 04:39:51 -0400 Received: from rock.gnat.com ([2620:20:4000:0:a9e:1ff:fe9b:1d1]:53798) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAVV7-0008Ex-60 for gcc-patches@gcc.gnu.org; Wed, 18 Sep 2019 04:39:49 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 54F29117D11; Wed, 18 Sep 2019 04:39:45 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id oeaVpotkXJEw; Wed, 18 Sep 2019 04:39:45 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 2404B117C70; Wed, 18 Sep 2019 04:39:45 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 22EB6702; Wed, 18 Sep 2019 04:39:45 -0400 (EDT) Date: Wed, 18 Sep 2019 04:39:45 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Improve efficiency of copying bit-packed slices Message-ID: <20190918083945.GA145164@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 2620:20:4000:0:a9e:1ff:fe9b:1d1 X-IsSubscribed: yes This patch substantially improves the efficiency of copying large slices of bit-packed arrays, by copying 32 bits at a time instead of 1 at a time. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-18 Bob Duff gcc/ada/ * exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield): The call to Copy_Bitfield is now enabled. (Expand_Assign_Array_Bitfield): Multiply 'Length times 'Component_Size "by hand" instead of using 'Size. --- gcc/ada/exp_ch5.adb +++ gcc/ada/exp_ch5.adb @@ -1411,12 +1411,21 @@ package body Exp_Ch5 is -- Compute the Size of the bitfield -- Note that the length check has already been done, so we can use the - -- size of either L or R. + -- size of either L or R; they are equal. We can't use 'Size here, + -- because sometimes bit fields get copied into a temp, and the 'Size + -- ends up being the size of the temp (e.g. an 8-bit temp containing + -- a 4-bit bit field). Size : constant Node_Id := - Make_Attribute_Reference (Loc, - Prefix => Duplicate_Subexpr (Name (N), True), - Attribute_Name => Name_Size); + Make_Op_Multiply (Loc, + Make_Attribute_Reference (Loc, + Prefix => + Duplicate_Subexpr (Name (N), True), + Attribute_Name => Name_Length), + Make_Attribute_Reference (Loc, + Prefix => + Duplicate_Subexpr (Name (N), True), + Attribute_Name => Name_Component_Size)); begin return Make_Procedure_Call_Statement (Loc, @@ -1466,10 +1475,7 @@ package body Exp_Ch5 is -- optimization in that case as well. We could complicate this code by -- actually looking for such volatile and independent components. - -- Note that Expand_Assign_Array_Bitfield is disabled for now. - - if False and then -- ??? - RTE_Available (RE_Copy_Bitfield) + if RTE_Available (RE_Copy_Bitfield) and then Is_Bit_Packed_Array (L_Type) and then Is_Bit_Packed_Array (R_Type) and then not Reverse_Storage_Order (L_Type)