From 59daeef4e14fbe21f3699e33713f29b5ed968562 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 25 Jul 2011 14:51:47 +0000 Subject: [PATCH] re PR tree-optimization/49809 (gimple_check failure at -O3) 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 | 6 ++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gnat.dg/opt18.adb | 31 +++++++++++++++++++++++++++++ gcc/testsuite/gnat.dg/opt18.ads | 29 +++++++++++++++++++++++++++ gcc/testsuite/gnat.dg/opt18_pkg.ads | 26 ++++++++++++++++++++++++ gcc/tree-ssa-phiopt.c | 4 ++-- 6 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/opt18.adb create mode 100644 gcc/testsuite/gnat.dg/opt18.ads create mode 100644 gcc/testsuite/gnat.dg/opt18_pkg.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6af45fe4a4f..ab7aee0c8c3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-07-25 Richard Sandiford + + 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 * system.h [__cplusplus]: Wrap C function declarations in extern "C". diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4869657af97..7a3c590fefe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-07-25 Richard Sandiford + + PR tree-optimization/49809 + * gnat.dg/opt18.adb, gnat.dg/opt18.ads, gnat.dg/opt18_pkg.ads: New + test. + 2011-07-25 Richard Guenther PR tree-optimization/49715 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; diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index ed8f9795e78..30eea319edc 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -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)) { -- 2.30.2