public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Bob Duff <duff@adacore.com>
Subject: [COMMITED] ada: Disable slice-of-component optimization in some cases
Date: Thu,  6 Oct 2022 11:26:43 +0200	[thread overview]
Message-ID: <20221006092643.260420-1-poulhies@adacore.com> (raw)

From: Bob Duff <duff@adacore.com>

This patch disables the Fast_Copy_Bitfield optimization in certain rare
cases that currently do not work (crash in gigi). We could improve
Expand_Assign_Array_Bitfield_Fast to handle these cases properly, but
that change is delicate, so for now, we simply disable the optimization.

gcc/ada/

	* exp_ch5.adb
	(Expand_Assign_Array_Loop_Or_Bitfield): Disable the
	Fast_Copy_Bitfield optimization in certain cases.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_ch5.adb | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index 209741c82cf..9669737a79b 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -1660,6 +1660,15 @@ package body Exp_Ch5 is
          return False;
       end Volatile_Or_Independent;
 
+      function Slice_Of_Packed_Component (L : Node_Id) return Boolean is
+        (Nkind (L) = N_Slice
+         and then Nkind (Prefix (L)) = N_Indexed_Component
+         and then Is_Bit_Packed_Array (Etype (Prefix (Prefix (L)))));
+      --  L is the left-hand side Name. Returns True if L is a slice of a
+      --  component of a bit-packed array. The optimization is disabled in
+      --  that case, because Expand_Assign_Array_Bitfield_Fast cannot
+      --  currently handle that case correctly.
+
       L : constant Node_Id := Name (N);
       R : constant Node_Id := Expression (N);
       --  Left- and right-hand sides of the assignment statement
@@ -1681,6 +1690,7 @@ package body Exp_Ch5 is
         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)
         and then not Volatile_Or_Independent (R, R_Type)
       then
-- 
2.34.1


                 reply	other threads:[~2022-10-06  9:27 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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20221006092643.260420-1-poulhies@adacore.com \
    --to=poulhies@adacore.com \
    --cc=duff@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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).