summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-25 14:51:47 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-25 14:51:47 +0000
commit728dcc716e13703f4165d957c2c6676d33ee374a (patch)
treecdfa49c7a1ddb854392a47feba4fa5e4346f02fe /gcc/testsuite/gnat.dg
parent80e4662c8234910551e2a9c8b71551b908770c0b (diff)
downloadgcc-728dcc716e13703f4165d957c2c6676d33ee374a.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176750 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r--gcc/testsuite/gnat.dg/opt18.adb31
-rw-r--r--gcc/testsuite/gnat.dg/opt18.ads29
-rw-r--r--gcc/testsuite/gnat.dg/opt18_pkg.ads26
3 files changed, 86 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/opt18.adb b/gcc/testsuite/gnat.dg/opt18.adb
new file mode 100644
index 00000000000..94c44beb6f7
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt18.adb
@@ -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
index 00000000000..85c3b634527
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt18.ads
@@ -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
index 00000000000..963fa3c3696
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt18_pkg.ads
@@ -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;