re PR tree-optimization/46351 (incorrect scalarization (2))
authorMartin Jambor <mjambor@suse.cz>
Wed, 10 Nov 2010 12:52:27 +0000 (13:52 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Wed, 10 Nov 2010 12:52:27 +0000 (13:52 +0100)
2010-11-10  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/46351
PR tree-optimization/46377
* tree-sra.c (type_internals_preclude_sra_p): Disqualify types with
aggregate bit-fields.

* testsuite/gnat.dg/opt10.adb: New file.
* testsuite/gnat.dg/opt10_pkg.ads: Likewise.
* testsuite/gnat.dg/opt11.adb: Likewise.
* testsuite/gnat.dg/opt11.ads: Likewise.

From-SVN: r166535

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/opt10.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt10_pkg.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt11.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt11.ads [new file with mode: 0644]
gcc/tree-sra.c

index 91b407c382af4780f9b391fb1f2683036596f57c..c14885e1aec6999d880dc91eb75191fcb044412f 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-10  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/46351
+       PR tree-optimization/46377
+       * tree-sra.c (type_internals_preclude_sra_p): Disqualify types with
+       aggregate bit-fields.
+
 2010-11-10  Joseph Myers  <joseph@codesourcery.com>
 
        * doc/tm.texi.in (TARGET_OPTION_TRANSLATE_TABLE): Remove.
index f3a0b1258d9072694ed9039414c6e5b8a56ed42e..0345145900460060aaf798e6d2618d6776d92106 100644 (file)
@@ -1,3 +1,12 @@
+2010-11-10  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/46351
+       PR tree-optimization/46377
+       * gnat.dg/opt10.adb: New file.
+       * gnat.dg/opt10_pkg.ads: Likewise.
+       * gnat.dg/opt11.adb: Likewise.
+       * gnat.dg/opt11.ads: Likewise.
+
 2010-11-10  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/boolean_conv.adb: New test.
diff --git a/gcc/testsuite/gnat.dg/opt10.adb b/gcc/testsuite/gnat.dg/opt10.adb
new file mode 100644 (file)
index 0000000..cb3cb0d
--- /dev/null
@@ -0,0 +1,26 @@
+-- { dg-do compile }
+-- { dg-options "-O2 }
+
+with Opt10_Pkg; use Opt10_Pkg;
+
+procedure Opt10 is
+
+   procedure Compare_Rep_Data (MA, MB : Rep_Message) is
+   begin
+      if MA.Data /= MB.Data then
+         raise Program_Error;
+      end if;
+   end;
+
+   procedure Check_Rep_For (Bit : Boolean) is
+      MA, MB : Rep_Message;
+   begin
+      Safe_Assign (MA, Bit);
+      Safe_Assign (MB, Bit);
+      Compare_Rep_Data (MA, MB);
+   end;
+
+begin
+   Check_Rep_For (Bit => False);
+end;
+
diff --git a/gcc/testsuite/gnat.dg/opt10_pkg.ads b/gcc/testsuite/gnat.dg/opt10_pkg.ads
new file mode 100644 (file)
index 0000000..8df6dca
--- /dev/null
@@ -0,0 +1,14 @@
+package Opt10_Pkg is
+
+   type Rep_Message is record
+      Bit : Boolean;
+      Data : String (1 .. 4);
+   end record;
+   for Rep_Message use record
+      Bit  at 0 range 0 .. 0;
+      Data at 0 range 1 .. 32;
+   end record;
+
+   procedure Safe_Assign (M : in out Rep_Message; Bit : Boolean);
+
+end;
diff --git a/gcc/testsuite/gnat.dg/opt11.adb b/gcc/testsuite/gnat.dg/opt11.adb
new file mode 100644 (file)
index 0000000..dca4804
--- /dev/null
@@ -0,0 +1,12 @@
+-- { dg-compile }
+-- { dg-options "-O" }
+
+package body Opt11 is
+
+   procedure Proc is
+      R : Rec;
+   begin
+      R := (others => <>);
+   end;
+
+end Opt11;
diff --git a/gcc/testsuite/gnat.dg/opt11.ads b/gcc/testsuite/gnat.dg/opt11.ads
new file mode 100644 (file)
index 0000000..983bf26
--- /dev/null
@@ -0,0 +1,17 @@
+package Opt11 is
+
+   type String_Ptr is access constant String;
+
+   type Form_Type is (Qualified, Unqualified);
+
+   type Rec is record
+      N1, N2, N3 : Natural;
+      Fixed : String_Ptr;
+      Form : Form_Type;
+      Is_Local : Boolean := True;
+   end record;
+   pragma Pack (Rec);
+
+   procedure Proc;
+
+end Opt11;
index 4f0d2e527d3451d3e2da01bfe54b396ebb17f64f..be1b45e6b9ca0db20b068dbf9eab5dc757c9f2eb 100644 (file)
@@ -653,7 +653,8 @@ type_internals_preclude_sra_p (tree type)
            if (TREE_THIS_VOLATILE (fld)
                || !DECL_FIELD_OFFSET (fld) || !DECL_SIZE (fld)
                || !host_integerp (DECL_FIELD_OFFSET (fld), 1)
-               || !host_integerp (DECL_SIZE (fld), 1))
+               || !host_integerp (DECL_SIZE (fld), 1)
+               || (DECL_BIT_FIELD (fld) && AGGREGATE_TYPE_P (ft)))
              return true;
 
            if (AGGREGATE_TYPE_P (ft)