diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2016-05-25 20:41:01 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2016-05-25 20:41:01 +0000 |
commit | a1ee3d25c416b8c61a5d1955ca5398fd6671e883 (patch) | |
tree | 793a264e2566b1ca06cd1bc77b31678385a44bf6 | |
parent | bbe1972d0b296dc44be41084c7fe70037be61cbe (diff) |
* tree-ssa-phiopt.c (factor_out_conditional_conversion): Remove
redundant test and bail out if the type of the new operand is not
a GIMPLE register type after stripping a VIEW_CONVERT_EXPR.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@236748 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt55.adb | 20 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt55.ads | 22 | ||||
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 9 |
5 files changed, 58 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0172c8ba154..43be10fe61e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-05-25 Eric Botcazou <ebotcazou@adacore.com> + + * tree-ssa-phiopt.c (factor_out_conditional_conversion): Remove + redundant test and bail out if the type of the new operand is not + a GIMPLE register type after stripping a VIEW_CONVERT_EXPR. + 2016-05-25 Uros Bizjak <ubizjak@gmail.com> * config/i386/i386.opt (ix86_target_flags_explicit): Remove. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f89efd33788..23dc60d29b5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-05-25 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/opt55.ad[sb]: New test. + 2016-05-25 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> * c-c++-common/Wduplicated-cond-1.c: Use smaller const literal. diff --git a/gcc/testsuite/gnat.dg/opt55.adb b/gcc/testsuite/gnat.dg/opt55.adb new file mode 100644 index 00000000000..70f486b2ee3 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt55.adb @@ -0,0 +1,20 @@ +-- { dg-do compile }
+-- { dg-options "-O" }
+
+package body Opt55 is
+
+ function Cond (B : Boolean; If_True, If_False : Date) return Date is
+ begin
+ if B then
+ return If_True;
+ else
+ return If_False;
+ end if;
+ end;
+
+ function F (C : Rec2; B : Boolean) return Date is
+ begin
+ return Cond (B, C.D1, C.D2);
+ end;
+
+end Opt55;
diff --git a/gcc/testsuite/gnat.dg/opt55.ads b/gcc/testsuite/gnat.dg/opt55.ads new file mode 100644 index 00000000000..fec3c9ae2ef --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt55.ads @@ -0,0 +1,22 @@ +package Opt55 is
+
+ type Date is record
+ D : Float;
+ end record;
+
+ type Rec1 (Kind : Boolean := False) is record
+ case Kind is
+ when True => N : Natural;
+ when False => null;
+ end case;
+ end record;
+
+ type Rec2 (D : Positive) is record
+ R : Rec1;
+ D1 : Date;
+ D2 : Date;
+ end record;
+
+ function F (C : Rec2; B : Boolean) return Date;
+
+end Opt55;
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index a752fe0fd1c..caf591bc529 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -438,15 +438,18 @@ factor_out_conditional_conversion (edge e0, edge e1, gphi *phi, /* Check if arg0 is an SSA_NAME and the stmt which defines arg0 is a conversion. */ arg0_def_stmt = SSA_NAME_DEF_STMT (arg0); - if (!is_gimple_assign (arg0_def_stmt) - || !gimple_assign_cast_p (arg0_def_stmt)) + if (!gimple_assign_cast_p (arg0_def_stmt)) return NULL; /* Use the RHS as new_arg0. */ convert_code = gimple_assign_rhs_code (arg0_def_stmt); new_arg0 = gimple_assign_rhs1 (arg0_def_stmt); if (convert_code == VIEW_CONVERT_EXPR) - new_arg0 = TREE_OPERAND (new_arg0, 0); + { + new_arg0 = TREE_OPERAND (new_arg0, 0); + if (!is_gimple_reg_type (TREE_TYPE (new_arg0))) + return NULL; + } if (TREE_CODE (arg1) == SSA_NAME) { |