Add missing check for gassign.

Message ID 333748b3-0caf-e888-812d-bdd8d2120a15@suse.cz
State New
Headers show
Series
  • Add missing check for gassign.
Related show

Commit Message

Martin Liška June 18, 2020, 7:42 a.m.
Hi.

We should check for gassign before doing gimple_assign_rhs_code and friends.

Ready to be installed after proper testing?

Thanks,
Martin

gcc/ChangeLog:

	* tree-vect-generic.c (expand_vector_condition): Check
	for gassign before inspecting RHS.
---
  gcc/tree-vect-generic.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.27.0

Comments

H.J. Lu via Gcc-patches June 18, 2020, 8:05 a.m. | #1
On Thu, Jun 18, 2020 at 9:42 AM Martin Liška <mliska@suse.cz> wrote:
>

> Hi.

>

> We should check for gassign before doing gimple_assign_rhs_code and friends.

>

> Ready to be installed after proper testing?


OK.

> Thanks,

> Martin

>

> gcc/ChangeLog:

>

>         * tree-vect-generic.c (expand_vector_condition): Check

>         for gassign before inspecting RHS.

> ---

>   gcc/tree-vect-generic.c | 5 +++--

>   1 file changed, 3 insertions(+), 2 deletions(-)

>

> diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c

> index fb955bbf3d2..83d399a7898 100644

> --- a/gcc/tree-vect-generic.c

> +++ b/gcc/tree-vect-generic.c

> @@ -957,8 +957,9 @@ expand_vector_condition (gimple_stmt_iterator *gsi)

>

>     if (code == SSA_NAME)

>       {

> -      gimple *assign = SSA_NAME_DEF_STMT (a);

> -      if (TREE_CODE_CLASS (gimple_assign_rhs_code (assign)) == tcc_comparison)

> +      gassign *assign = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (a));

> +      if (assign != NULL

> +         && TREE_CODE_CLASS (gimple_assign_rhs_code (assign)) == tcc_comparison)

>         {

>           a_is_comparison = true;

>           a1 = gimple_assign_rhs1 (assign);

> --

> 2.27.0

>

Patch

diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index fb955bbf3d2..83d399a7898 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -957,8 +957,9 @@  expand_vector_condition (gimple_stmt_iterator *gsi)
  
    if (code == SSA_NAME)
      {
-      gimple *assign = SSA_NAME_DEF_STMT (a);
-      if (TREE_CODE_CLASS (gimple_assign_rhs_code (assign)) == tcc_comparison)
+      gassign *assign = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (a));
+      if (assign != NULL
+	  && TREE_CODE_CLASS (gimple_assign_rhs_code (assign)) == tcc_comparison)
  	{
  	  a_is_comparison = true;
  	  a1 = gimple_assign_rhs1 (assign);