OSDN Git Service

* tree-sra.c (scalarize_use): Create another temporary with the proper
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 7 Dec 2008 13:04:57 +0000 (13:04 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 7 Dec 2008 13:04:57 +0000 (13:04 +0000)
type for signed types in the use_all && !is_output bitfield case.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142537 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 0c889a1..85cd145 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree-sra.c (scalarize_use): Create another temporary with the proper
+       type for signed types in the use_all && !is_output bitfield case.
+
 2008-12-06  Steven Bosscher  <steven@gcc.gnu.org>
 
        PR rtl-optimization/36365
index d7490b0..d7b0da0 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/aggr10.adb: New test.
+       * gnat.dg/aggr10_pkg.ads: New helper.
+
 2008-12-06  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/38425
diff --git a/gcc/testsuite/gnat.dg/aggr10.adb b/gcc/testsuite/gnat.dg/aggr10.adb
new file mode 100644 (file)
index 0000000..6fbb8ed
--- /dev/null
@@ -0,0 +1,23 @@
+-- { dg-do compile }
+-- { dg-options "-O2" }
+
+with Aggr10_Pkg; use Aggr10_Pkg;
+
+procedure Aggr10 is
+
+   No_Name_Location : constant Name_Location :=
+                        (Name     => Name_Id'First,
+                         Location => Int'First,
+                         Source   => Source_Id'First,
+                         Except   => False,
+                         Found    => False);
+
+   Name_Loc : Name_Location;
+
+begin
+   Name_Loc := Get;
+   if Name_Loc = No_Name_Location then  -- { dg-bogus "comparison always false" }
+      raise Program_Error;
+   end if;
+   Set (Name_Loc);
+end;
diff --git a/gcc/testsuite/gnat.dg/aggr10_pkg.ads b/gcc/testsuite/gnat.dg/aggr10_pkg.ads
new file mode 100644 (file)
index 0000000..92400f9
--- /dev/null
@@ -0,0 +1,18 @@
+package Aggr10_Pkg is
+
+   type Name_Id is range 300_000_000 .. 399_999_999;
+   type Int is range -2 ** 31 .. +2 ** 31 - 1;
+   type Source_Id is range 5_000_000 .. 5_999_999;
+
+   type Name_Location is record
+      Name     : Name_Id;
+      Location : Int;
+      Source   : Source_Id;
+      Except   : Boolean;
+      Found    : Boolean := False;
+   end record;
+
+   function Get return Name_Location;
+   procedure Set (Name_Loc : Name_Location);
+
+end Aggr10_Pkg;
index 8cada85..aa16193 100644 (file)
@@ -3223,12 +3223,20 @@ scalarize_use (struct sra_elt *elt, tree *expr_p, gimple_stmt_iterator *gsi,
       if (!elt->use_block_copy)
        {
          tree type = TREE_TYPE (bfexpr);
-         tree var, vpos;
+         tree var = make_rename_temp (type, "SR"), tmp, vpos;
+         gimple st = NULL;
 
-         if (!TYPE_UNSIGNED (type))
-           type = unsigned_type_for (type);
+         gimple_assign_set_rhs1 (stmt, var);
+         update = true;
 
-         var = make_rename_temp (type, "SR");
+         if (!TYPE_UNSIGNED (type))
+           {
+             type = unsigned_type_for (type);
+             tmp = make_rename_temp (type, "SR");
+             st = gimple_build_assign (var,
+                                       fold_convert (TREE_TYPE (var), tmp));
+             var = tmp;
+           }
 
          gimple_seq_add_stmt (&seq,
                                gimple_build_assign
@@ -3245,8 +3253,8 @@ scalarize_use (struct sra_elt *elt, tree *expr_p, gimple_stmt_iterator *gsi,
          sra_explode_bitfield_assignment
            (var, vpos, true, &seq, blen, bpos, elt);
 
-         gimple_assign_set_rhs1 (stmt, var);
-         update = true;
+         if (st)
+           gimple_seq_add_stmt (&seq, st);
        }
       else
        sra_sync_for_bitfield_assignment