From patchwork Tue Nov 7 09:19:37 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: 162335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp112109vqo; Tue, 7 Nov 2023 01:22:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCxz5qLMg4nCp/wIblPlmFtxxNqCrF1exlUV3p17mfaRYhhs6oVs5svrgbb12ACTnQKIGL X-Received: by 2002:a05:622a:1648:b0:418:af4c:1850 with SMTP id y8-20020a05622a164800b00418af4c1850mr33212062qtj.56.1699348942966; Tue, 07 Nov 2023 01:22:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699348942; cv=pass; d=google.com; s=arc-20160816; b=fxBhXkCwX1f+mo+JZxrRQ7waSqTPGdl+x0aO0RSQezJQJiwkbL4ro0YmNlIHxOUQRs UHsuBwCh1wwJjfbn/jU/P+hLemVMkj9zEDOkWC8yu2p7k31+uq7Un0PjCN9V4VXGW6QL 5NiPUqLE0iY0AnBr63VnoVkMn4Ge2W2IivDwvak0rOTkmWkRuw53GvUIeBtbYW2/Qrxv XXiuLW6sDH8jw/pWku4MTpvlB/Udjxi/+qChmQ8bTQEiQZbA/NOObMlQpMvZFMztnhiT 1/pH8tfDZg8R3KmeUpS/kJfVFpGB33qMgROTjtNif5HpR558eS1FvoVUoLt6qBwrEDfc S7ow== 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=RvtQ/27SNLzL/L1d3dh56A8E78sQjsKVKBHtl1tKCUY=; fh=QRb7QY4BZ0mIIAPiH2G4K0PcYKRtRn2i5A6VLUA8cN4=; b=n3zzBuk6yR4Oavc2fCWOzp8dEb0T975ZYf62EU92yJiX3vYfU/K+Ct3JBUDaP4F9o6 zXmNgWecRNopv09O3TpE3jPDqYQbmVm8DFKc7qEZesN+gqZrLW0KFVI7d8xTcPSoL45f 1BoaM3PgXm043TLEANOgSbNpZ1Ae+3w6hFf5tatJlgUYapy9PvYzeIe9K3eIED3hqDdQ ZYTG24/dL2U6OfSPkTH5oSFeny5yiVMuQpV3bqceqqHXvpQO0W9Ew8Dy2OMKwgWGzG/3 nbgILDSBI8GOPa6SzOaMsMOWSO0F1o0z4KXdXYSa0BiwNVXnmiE8kgcp4UYoioFoEa12 +mgw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b="EOU/nWPJ"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id g13-20020ac8580d000000b004069466b1c0si6504483qtg.562.2023.11.07.01.22.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:22:22 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b="EOU/nWPJ"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 6F17A388302A for ; Tue, 7 Nov 2023 09:21:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 82E89385624C for ; Tue, 7 Nov 2023 09:19:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82E89385624C 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 82E89385624C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699348785; cv=none; b=azwNlnPgDcm0N+V4I+1fPY2Vts4m+Ut/nSSJgFPvknwfcoko3DM5Lp31Be6+hV+jERZau4RZNVMGWGGLNToisY1xT3OkOMwhiX6Io1Mt4ydrga2WoiSc9FLH8S121hWj3f8qgRkO31+HaxMmUnrcd+UxvlzS5FlVdUT2LYBI+6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699348785; c=relaxed/simple; bh=xpQMp5yTb1yeZMyX1SXZtQbF8vk3a62DstNqJhT/cx4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=fXuZMntTHwL4kzsDkQYGw8pfHAiueRySyHQPx8aq7kCB567E36qzBghpmwnMqrism5G4XncdoiH3pKs2sAzRNCGyQmL3QZ+/3ZIwyyEBywU6iDaJ+6a01i2liPHyrCifVZ+p7LchFt3tlVkRxOkOhThPjLdnn8c1pl6qNG2bjpM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-32dcd3e5f3fso3265294f8f.1 for ; Tue, 07 Nov 2023 01:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1699348782; x=1699953582; 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=RvtQ/27SNLzL/L1d3dh56A8E78sQjsKVKBHtl1tKCUY=; b=EOU/nWPJbVher/R+PwzWBOwGgMrFpscDUFbDMjmaD3gnIKPhh2rY7r+pPLoNHNUu7z lTjY0YvBq6duc2vZCID0S/H78NjHyw4zFUVfidAHKLXGYTfIj9XTIsfH6aox+7tYo8ZP bEPZHAlt0KJKbx5VEUgl707rbGiXzFytJ6R7w4q0xlJx4yhIdZB8wUDXd2xFjt6fZW3k SCAcuXKruBmQLO13jHUd2ljWbXYrAV8jzFgxPOMwY7dcivNtpVgIfSgXqy8imYNT/o/4 R7oqn7q+nJKfs8YEMzhZ7I0eJ82AumyF1Ybc1QyghqUNkqUNm5EE6wnV/mlgyR8iIv+P I6zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699348782; x=1699953582; 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=RvtQ/27SNLzL/L1d3dh56A8E78sQjsKVKBHtl1tKCUY=; b=LDUuMAhMDxpGpF2ufHoAWn22UNKCM76ER67IYy0ki8PiGq5HyAbDmmsC0s/U+1y5bB db38LOkCnPJScqRCpQmj2CQ6bT2eT7JvDAdm/rq7/gtZ2LEtzjgsuz1xAVJwkb8quNYX JQ2dkwQ4Rvvuy9uLcoLaPYKXyW/8xT2mSvnQTb4Q5ss7l1lTQjfJ46qwN7hsJrLUzdh+ 9wbH6GxnrTtctSNSiK+gtqqk6udQSwHroCi2A9K+oZ0K0W80ADwouf6/1tNPB9bqgaVY s5MS1xjUhbn4uu8Pp+NTbcXHBvYTHCRsrk+muBgFJRODiFFViIOs5tIKC1/7x8ys/OKQ P6sw== X-Gm-Message-State: AOJu0YzgHN008YZlb/SqQ7DNSKwBRT2Ua/JodNLbTifA3y/0MjtVL0To Kk/d6xB7DtZHpK06or5jHPfsK8EaH47Cq9STTd3nlQ== X-Received: by 2002:a5d:6d49:0:b0:32d:e478:9d70 with SMTP id k9-20020a5d6d49000000b0032de4789d70mr24480197wri.14.1699348782256; Tue, 07 Nov 2023 01:19:42 -0800 (PST) Received: from localhost.localdomain ([2001:861:3382:1a90:dbc1:a1d1:2e58:4040]) by smtp.gmail.com with ESMTPSA id k4-20020a5d6d44000000b0032dc1fc84f2sm1800693wri.46.2023.11.07.01.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:19:41 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Simplify handling of known values in expansion of packed arrays Date: Tue, 7 Nov 2023 10:19:37 +0100 Message-ID: <20231107091937.3905649-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: 1781896517352059630 X-GMAIL-MSGID: 1781896517352059630 From: Piotr Trojanek If an expression value is not known at compile time, it can be represented with No_Uint and doesn't require a dedicated flag. Code cleanup; behavior is unaffected. gcc/ada/ * exp_pakd.adb (Expand_Bit_Packed_Element_Set): Remove Rhs_Val_Known; represent unknown value by assigning Rhs_Val with No_Uint. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_pakd.adb | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb index 1641e8a51c2..ef0ec1e0014 100644 --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -1073,12 +1073,9 @@ package body Exp_Pakd is New_Lhs : Node_Id; New_Rhs : Node_Id; - Rhs_Val_Known : Boolean; - Rhs_Val : Uint; + Rhs_Val : Uint; -- If the value of the right hand side as an integer constant is - -- known at compile time, Rhs_Val_Known is set True, and Rhs_Val - -- contains the value. Otherwise Rhs_Val_Known is set False, and - -- the Rhs_Val is undefined. + -- known at compile time, Rhs_Val contains the value. function Get_Shift return Node_Id; -- Function used to get the value of Shift, making sure that it @@ -1230,8 +1227,7 @@ package body Exp_Pakd is -- Determine if right side is all 0 bits or all 1 bits if Compile_Time_Known_Value (Rhs) then - Rhs_Val := Expr_Rep_Value (Rhs); - Rhs_Val_Known := True; + Rhs_Val := Expr_Rep_Value (Rhs); -- The following test catches the case of an unchecked conversion of -- an integer literal. This results from optimizing aggregates of @@ -1240,19 +1236,17 @@ package body Exp_Pakd is elsif Nkind (Rhs) = N_Unchecked_Type_Conversion and then Compile_Time_Known_Value (Expression (Rhs)) then - Rhs_Val := Expr_Rep_Value (Expression (Rhs)); - Rhs_Val_Known := True; + Rhs_Val := Expr_Rep_Value (Expression (Rhs)); else - Rhs_Val := No_Uint; - Rhs_Val_Known := False; + Rhs_Val := No_Uint; end if; -- Some special checks for the case where the right hand value is -- known at compile time. Basically we have to take care of the -- implicit conversion to the subtype of the component object. - if Rhs_Val_Known then + if Present (Rhs_Val) then -- If we have a biased component type then we must manually do the -- biasing, since we are taking responsibility in this case for @@ -1289,7 +1283,7 @@ package body Exp_Pakd is -- First we deal with the "and" - if not Rhs_Val_Known or else Rhs_Val /= Cmask then + if No (Rhs_Val) or else Rhs_Val /= Cmask then declare Mask1 : Node_Id; Lit : Node_Id; @@ -1319,7 +1313,7 @@ package body Exp_Pakd is -- Then deal with the "or" - if not Rhs_Val_Known or else Rhs_Val /= 0 then + if No (Rhs_Val) or else Rhs_Val /= 0 then declare Or_Rhs : Node_Id; @@ -1359,7 +1353,7 @@ package body Exp_Pakd is end Fixup_Rhs; begin - if Rhs_Val_Known + if Present (Rhs_Val) and then Compile_Time_Known_Value (Get_Shift) then Or_Rhs := @@ -1387,7 +1381,7 @@ package body Exp_Pakd is -- which will be properly retyped when we analyze and -- resolve the expression. - elsif Rhs_Val_Known then + elsif Present (Rhs_Val) then -- Note that Rhs_Val has already been normalized to -- be an unsigned value with the proper number of bits.