public inbox for
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <>
Cc: Bob Duff <>
Subject: [COMMITED] ada: Clean up slice-of-component optimization
Date: Thu,  6 Oct 2022 11:28:10 +0200	[thread overview]
Message-ID: <> (raw)

From: Bob Duff <>

In the recursive case of Volatile_Or_Independent = False for array
types, fall through into later checks, so for example we check
the type of the prefix of a slice. The pattern here is "return True
in certain cases, otherwise fall through into the final 'return False'".

Remove check for "Ndim = 1"; if Slices is True, then the number of
dimensions is necessarily 1, because Ada doesn't have multi-dimensional


	* exp_ch5.adb
	(Expand_Assign_Array_Loop_Or_Bitfield): Minor cleanups.

Tested on x86_64-pc-linux-gnu, committed on master.
 gcc/ada/exp_ch5.adb | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index 9669737a79b..d5d66d961de 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -1632,7 +1632,10 @@ package body Exp_Ch5 is
          end if;
          if Is_Array_Type (Typ) then
-            return Volatile_Or_Independent (Empty, Component_Type (Typ));
+            if Volatile_Or_Independent (Empty, Component_Type (Typ)) then
+               return True;
+            end if;
          elsif Is_Record_Type (Typ) then
                Comp : Entity_Id := First_Component (Typ);
@@ -1688,7 +1691,6 @@ package body Exp_Ch5 is
         and then Is_Bit_Packed_Array (R_Type)
         and then not Reverse_Storage_Order (L_Type)
         and then not Reverse_Storage_Order (R_Type)
-        and then Ndim = 1
         and then Slices
         and then not Slice_Of_Packed_Component (L)
         and then not Volatile_Or_Independent (L, L_Type)

                 reply	other threads:[~2022-10-06  9:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).