re PR tree-optimization/49809 (gimple_check failure at -O3)
authorRichard Sandiford <richard.sandiford@linaro.org>
Mon, 25 Jul 2011 14:51:47 +0000 (14:51 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Mon, 25 Jul 2011 14:51:47 +0000 (14:51 +0000)
gcc/
PR tree-optimization/49809
* tree-ssa-phiopt.c (cond_if_else_store_replacement): Use
gimple_get_lhs instead of gimple_assign_lhs.

gcc/testsuite/
PR tree-optimization/49809
* gnat.dg/opt18.adb, gnat.dg/opt18.ads, gnat.dg/opt18_pkg.ads: New
test.

From-SVN: r176750

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/opt18.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt18.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt18_pkg.ads [new file with mode: 0644]
gcc/tree-ssa-phiopt.c

index 6af45fe4a4f917da5e83d6b860a188dad465cebf..ab7aee0c8c38e175519dcb6b8e88906706050c6a 100644 (file)
@@ -1,3 +1,9 @@
+2011-07-25  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       PR tree-optimization/49809
+       * tree-ssa-phiopt.c (cond_if_else_store_replacement): Use
+       gimple_get_lhs instead of gimple_assign_lhs.
+
 2011-07-25  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * system.h [__cplusplus]: Wrap C function declarations in extern "C".
index 4869657af974ba1bce436edcef5dbb1c7b16d4c1..7a3c590fefef2551c5403c9de01d63ae385d848a 100644 (file)
@@ -1,3 +1,9 @@
+2011-07-25  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       PR tree-optimization/49809
+       * gnat.dg/opt18.adb, gnat.dg/opt18.ads, gnat.dg/opt18_pkg.ads: New
+       test.
+
 2011-07-25  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/49715
diff --git a/gcc/testsuite/gnat.dg/opt18.adb b/gcc/testsuite/gnat.dg/opt18.adb
new file mode 100644 (file)
index 0000000..94c44be
--- /dev/null
@@ -0,0 +1,31 @@
+-- { dg-do compile }
+-- { dg-options "-O3" }
+
+with Opt18_Pkg; use Opt18_Pkg;
+
+package body Opt18 is
+
+   function Mag (Item : in Cart_Vector_Type) return Float is
+   begin
+      return Sqrt (Item (X) * Item (X) + Item (Y) * Item (Y)
+                   + Item (Z) * Item (Z));
+   end;
+
+   function Unit_Quaternion_To_Mag_Axis (Quaternion : in Unit_Quaternion_Type)
+   return Mag_Axis_Type is
+      Sin_Half : Float
+         := Mag (Cart_Vector_Type'(Quaternion.X, Quaternion.Y, Quaternion.Z));
+   begin
+      if Sin_Half > 3.0 * First_Order_Trig then
+         return
+            (Mag  => Atan2 (Double_Trig (Unchecked_Trig_Pair (Sin_Half,
+                                                              Quaternion.S))),
+             Axis => Unit_Vector_Type'(Quaternion.X / Sin_Half,
+                                       Quaternion.Y / Sin_Half,
+                                       Quaternion.Z / Sin_Half));
+      else
+         return (0.0, X_Unit);
+      end if;
+   end;
+
+end Opt18;
diff --git a/gcc/testsuite/gnat.dg/opt18.ads b/gcc/testsuite/gnat.dg/opt18.ads
new file mode 100644 (file)
index 0000000..85c3b63
--- /dev/null
@@ -0,0 +1,29 @@
+package Opt18 is
+
+   type Cart_Axis_Type is (X, Y, Z);
+
+   type Cart_Vector_Type is array (Cart_Axis_Type) of Float;
+
+   function Mag (Item : in Cart_Vector_Type) return Float;
+
+   type Unit_Vector_Type is array (Cart_Axis_Type) of Float;
+
+   type Mag_Axis_Type is
+   record
+      Mag  : Float;
+      Axis : Unit_Vector_Type;
+   end record;
+
+   type Unit_Quaternion_Type is record
+      X : Float;
+      Y : Float;
+      Z : Float;
+      S : Float;
+   end record;
+
+   function Unit_Quaternion_To_Mag_Axis (Quaternion : in Unit_Quaternion_Type)
+     return Mag_Axis_Type;
+
+   X_Unit : constant Unit_Vector_Type := (1.0, 0.0, 0.0);
+
+end Opt18;
diff --git a/gcc/testsuite/gnat.dg/opt18_pkg.ads b/gcc/testsuite/gnat.dg/opt18_pkg.ads
new file mode 100644 (file)
index 0000000..963fa3c
--- /dev/null
@@ -0,0 +1,26 @@
+package Opt18_Pkg is
+
+   pragma Pure;
+
+   type Limit_Type is record
+      Low  : Float;
+      High : Float;
+   end record;
+
+   function First_Order_Trig return Float;
+
+  type Trig_Pair_Type is
+   record
+      Sin : Float;
+      Cos : Float;
+   end record;
+
+   function Atan2 (Trig : in Trig_Pair_Type) return Float;
+
+   function Unchecked_Trig_Pair (Sin, Cos : in Float) return Trig_Pair_Type;
+
+   function Double_Trig (Trig : in Trig_Pair_Type) return Trig_Pair_Type;
+
+   function Sqrt (X : Float) return Float;
+
+end Opt18_Pkg;
index ed8f9795e788fa65c70659de6229886162e070fe..30eea319edcc21e2d7bb2179eb135ace89701043 100644 (file)
@@ -1454,7 +1454,7 @@ cond_if_else_store_replacement (basic_block then_bb, basic_block else_bb,
         continue;
 
       then_store = DR_STMT (then_dr);
-      then_lhs = gimple_assign_lhs (then_store);
+      then_lhs = gimple_get_lhs (then_store);
       found = false;
 
       FOR_EACH_VEC_ELT (data_reference_p, else_datarefs, j, else_dr)
@@ -1463,7 +1463,7 @@ cond_if_else_store_replacement (basic_block then_bb, basic_block else_bb,
             continue;
 
           else_store = DR_STMT (else_dr);
-          else_lhs = gimple_assign_lhs (else_store);
+          else_lhs = gimple_get_lhs (else_store);
 
           if (operand_equal_p (then_lhs, else_lhs, 0))
             {