From patchwork Tue Nov 7 09:19:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 162334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp111993vqo; Tue, 7 Nov 2023 01:22:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMeOZcaxYhvASHBELBQOd0fiXZynuMUHNp3eBm9wR+cXuyh6G4ZaFSuzg5GRA772pPVudA X-Received: by 2002:a05:620a:4089:b0:778:8cdb:88ff with SMTP id f9-20020a05620a408900b007788cdb88ffmr2306293qko.31.1699348924512; Tue, 07 Nov 2023 01:22:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699348924; cv=pass; d=google.com; s=arc-20160816; b=L3CqVFwkC9USgH9OcDMfb2BFRKKir99G9l0py1S4TooRyzYJuNZq2eSQR8nozO1K6h YAzUcqdK1X22tTPVwS2j5ckD2K952cw791iHWaDvO8z6pdxkzfZgVF54I20r/RmwOJmL w2svCd0eTLBita7swYmgVlZxvaeJyEX47dulAAd9R8HcE6T0Pfdpe6V2Zq8NIrXiwYhp XG9c+FTByd1tHIwUyTA3eTDzTtg7PxPByY5+RnYhkZlAkbvrUklN0+U4sxSsLO18BEey g+Hqe4ASsPTQcjbqHKYeMJIqBU5ekluslGwfA7NcvZu0M+rAh0GkZMlbI5giNMVTHNGl 7enA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Xmxhf7tn7nEJo+iBTNz3j3H79ZKhru8FBWuMdrVbZrU=; fh=QRb7QY4BZ0mIIAPiH2G4K0PcYKRtRn2i5A6VLUA8cN4=; b=zjEQkuX2aFUBuoZ4hgU6StljDNQjNzaqfGU+wa7ZUZnd22D8U4erg+FleOw1NilNgH IUmukKlNEIW7k+h0uxWSlbONFaU5ZNumbx3fAf4zB2GddJvBvzNoD7j6DFVxi6pG6r0V fT2tPznNFvgLSss2vrI2OhGBA6GTMlXwgRksAr78qMFMMiJyqlIXUPIkuQ9QO3gL4LQH fVYe5pFJVBqwBgeJ9KzhDjm2hcl8VAed3tZHT65TLj00wzc8um44wnmUh4RuYEpzNk3O e7BDrlfNFOwfVJGenNl1diP66evGUGvOvAGnAhXgM87RPaAfUdWMVQ+HR2LwMDNoQeFO kBgA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=a74N2g4w; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o17-20020a05620a2a1100b0077594d37ca1si6875423qkp.562.2023.11.07.01.22.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:22:04 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=a74N2g4w; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5A5ED38708B4 for ; Tue, 7 Nov 2023 09:21:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 0EF58385DC0B for ; Tue, 7 Nov 2023 09:19:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0EF58385DC0B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0EF58385DC0B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::332 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699348796; cv=none; b=LdQYlNWqPWtkqcCENKV/0bGeWarzvFyLu5JcdXFL8Rw3PbKgjDfKn7NjpWMz0lsSPySKBPmZMjYE55Rbd2qa2J5iJHpWwmhES2EV6lJt6HOjKvApYxj5wEP5tTMsADBgwzrrbCQlssvJzF1qRvJD+3guPZhcoiyBHQMuDNO9WA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699348796; c=relaxed/simple; bh=X/OstuoKAP6/BeH/e20Ue/lJtCGYLatNwE2ZKSojDSA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=E8BUxX5p+6X9msdZd6w5+pEs7avGm9YY0UQQjpV34Dc9i+y0hA9c2hyRTTJh4jiZTEtMxq/o55UDWQV104V5vfKOoPPg6jQlcUDAgB6O7b9pNRvE0zaGk2uRdSKJdyIVMY0V7AFdl31k5hh4Y7SHaeeRs+9Hyk9LJ7czFa1BPKg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4083f61312eso41163085e9.3 for ; Tue, 07 Nov 2023 01:19:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1699348794; x=1699953594; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Xmxhf7tn7nEJo+iBTNz3j3H79ZKhru8FBWuMdrVbZrU=; b=a74N2g4wD4us5woL3xy23dL7dLP/j+fVFdrYs1JdR1Sry/3O6Dz2DWG964pMdJJ8E7 mIPeWBmX5VOXKMbJGlMU1RrjIRv4CYw/LrecmGee2kcYIXKn0pv9wFciDT4DShNO4Kn6 /i/uwMyd/KvwjsF6TQX0P99O1AbY23h5ip4G9aSeVVYI0oNoAiG+FO45tLYW6a/EWcoe dyQW/WPNR0J2py9YsGdGacZMZvBBmxOLfEI90sft/ZkPdEoqSBRnsBzsdp0HbL/ZLZtt Cy7LKcbHPuZ1lnlomLif6GVWksXfdJGLYQPR0Y01h5KJHxltUSx6v2Me+hSYkho3kzdH Gbog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699348794; x=1699953594; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Xmxhf7tn7nEJo+iBTNz3j3H79ZKhru8FBWuMdrVbZrU=; b=gtD1MqG2CRRWwsxSnGoP8obyjmeL5CF1xWEHa36QMJfcSGCRm8aPCl10MgYSTKBNJ2 NggZ7kku14RhSl2781xCmwY8ENX9Ng9X8Uim2l2wFsYBL+uXDmO6dr7+lMvMBs8ObM/9 /Lp9Eza2yEgE68t3QalGg8ThRaHCCYDWllEazyANjf/HzmgTwIpW85fEUMwVJeSUTDU7 lPqyqep4q7+nF2+tJb5OEd5AMAEPR47jjkXmeTBU2jCvNyA7iFlfnT7qnpw3+gyYnBZm TLbgfszWEZ+JUqxtNbM1ZqNZfc4hnUJv1NZt/XsGDQRwrsF6kNvEbv4muG+18Kc7FTLO 8D+Q== X-Gm-Message-State: AOJu0YwGAivkY/wxeIZ57g1/b2uSoJFXHUP/Z9ZuMB2nqjs4qc2DLo5L iI+qpNSQx4gzvMXXBsf1SJ9KV3WKcAUX5+Nu6WYLLg== X-Received: by 2002:a05:600c:19d3:b0:401:d803:6243 with SMTP id u19-20020a05600c19d300b00401d8036243mr2121557wmq.32.1699348793650; Tue, 07 Nov 2023 01:19:53 -0800 (PST) Received: from localhost.localdomain ([2001:861:3382:1a90:dbc1:a1d1:2e58:4040]) by smtp.gmail.com with ESMTPSA id p6-20020a05600c358600b004053a6b8c41sm14739286wmq.12.2023.11.07.01.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:19:53 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Simplify expansion of packed array assignments Date: Tue, 7 Nov 2023 10:19:51 +0100 Message-ID: <20231107091951.3905875-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781896497991156056 X-GMAIL-MSGID: 1781896497991156056 From: Piotr Trojanek When expanding assignment to a packed array object, e.g. a formal parameter with mode OUT that might have unconstrained type, we took the component type and component size from the constrained actual subtype. It is simpler to take these properties from the nominal type of the assigned object. Semantics is unaffected, because constraining the array doesn't change the type or size of the array components. gcc/ada/ * exp_pakd.adb (Expand_Bit_Packed_Element_Set): Change Ctyp and Csiz from variables to constants and compute them using the nominal type of the assigned array object. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_pakd.adb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb index 68f0db3d56d..2b92c467187 100644 --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -1059,10 +1059,12 @@ package body Exp_Pakd is Obj : Node_Id; Atyp : Entity_Id; PAT : Entity_Id; - Ctyp : Entity_Id; - Csiz : Int; Cmask : Uint; + Arr_Typ : constant Entity_Id := Etype (Prefix (Lhs)); + Ctyp : constant Entity_Id := Component_Type (Arr_Typ); + Csiz : constant Int := UI_To_Int (Component_Size (Arr_Typ)); + Shift : Node_Id; -- The expression for the shift value that is required @@ -1111,8 +1113,6 @@ package body Exp_Pakd is Convert_To_Actual_Subtype (Obj); Atyp := Etype (Obj); PAT := Packed_Array_Impl_Type (Atyp); - Ctyp := Component_Type (Atyp); - Csiz := UI_To_Int (Component_Size (Atyp)); -- We remove side effects, in case the rhs modifies the lhs, because we -- are about to transform the rhs into an expression that first READS