public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-4866] tree-optimization/111916 - SRA of BIT_FIELD_REF of constant pool entries
@ 2023-10-23 13:33 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-10-23 13:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:458db9b6149b2e9bef94ab76909eb914ed9f675a

commit r14-4866-g458db9b6149b2e9bef94ab76909eb914ed9f675a
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Oct 23 14:08:41 2023 +0200

    tree-optimization/111916 - SRA of BIT_FIELD_REF of constant pool entries
    
    The following adjusts a leftover BIT_FIELD_REF special-casing to only
    cover the cases general code doesn't handle.
    
            PR tree-optimization/111916
            * tree-sra.cc (sra_modify_assign): Do not lower all
            BIT_FIELD_REF reads that are sra_handled_bf_read_p.
    
            * gcc.dg/torture/pr111916.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr111916.c | 16 ++++++++++++++++
 gcc/tree-sra.cc                         |  3 ++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/torture/pr111916.c b/gcc/testsuite/gcc.dg/torture/pr111916.c
new file mode 100644
index 000000000000..2873045aaa43
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr111916.c
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+
+#pragma pack(1)
+struct A {
+  int b : 4;
+  int c : 11;
+  int d : 2;
+  int e : 5;
+} f;
+int main()
+{
+  struct A g = {1, 1, 1, 1};
+  while (!g.b)
+    f = g;
+  return 0;
+}
diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index f8dff8b27d76..b985dee6964d 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -4275,7 +4275,8 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi)
 
   if (TREE_CODE (rhs) == REALPART_EXPR || TREE_CODE (lhs) == REALPART_EXPR
       || TREE_CODE (rhs) == IMAGPART_EXPR || TREE_CODE (lhs) == IMAGPART_EXPR
-      || TREE_CODE (rhs) == BIT_FIELD_REF || TREE_CODE (lhs) == BIT_FIELD_REF)
+      || (TREE_CODE (rhs) == BIT_FIELD_REF && !sra_handled_bf_read_p (rhs))
+      || TREE_CODE (lhs) == BIT_FIELD_REF)
     {
       modify_this_stmt = sra_modify_expr (gimple_assign_rhs1_ptr (stmt),
 					  gsi, false);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-23 13:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 13:33 [gcc r14-4866] tree-optimization/111916 - SRA of BIT_FIELD_REF of constant pool entries Richard Biener

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