From: Eric Botcazou Date: Wed, 25 May 2016 20:41:01 +0000 (+0000) Subject: tree-ssa-phiopt.c (factor_out_conditional_conversion): Remove redundant test and... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a88a7b22c9d0df1068bdc92522ea805d0edf676f;p=gcc.git tree-ssa-phiopt.c (factor_out_conditional_conversion): Remove redundant test and bail out if the type of the new operand is not a... * 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. From-SVN: r236748 --- 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 + + * 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 * 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 + + * gnat.dg/opt55.ad[sb]: New test. + 2016-05-25 Senthil Kumar Selvaraj * 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) {