[PATCH] Fix ICE with MASK_LOAD and -fno-tree-dce (PR tree-optimization/60559)

Richard Biener rguenther@suse.de
Wed Mar 19 09:18:00 GMT 2014


On Tue, 18 Mar 2014, Jakub Jelinek wrote:

> Hi!
> 
> With -fno-tree-dce the scalar MASK_LOAD isn't removed from the IL and we ICE
> on it during expansion (as we support only the vector loads, if those aren't
> supported, MASK_LOAD is either not created by if-conversion at all, or
> vectorization refuses to vectorize the loop and thus it is cfg cleaned up
> away.
> 
> The following patch replaces the scalar MASK_LOAD manually with load of
> zero, similarly how we do it for vectorizable calls.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2014-03-18  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/60559
> 	* vectorizable_mask_load_store): Replace scalar MASK_LOAD
> 	with build_zero_cst assignment.
> 
> 	* g++.dg/vect/pr60559.cc: New test.
> 
> --- gcc/tree-vect-stmts.c.jj	2014-03-03 08:24:33.000000000 +0100
> +++ gcc/tree-vect-stmts.c	2014-03-18 14:01:40.969657763 +0100
> @@ -2038,6 +2038,15 @@ vectorizable_mask_load_store (gimple stm
>  	    STMT_VINFO_RELATED_STMT (prev_stmt_info) = new_stmt;
>  	  prev_stmt_info = vinfo_for_stmt (new_stmt);
>  	}
> +
> +      /* Ensure that even with -fno-tree-dce the scalar MASK_LOAD is removed
> +	 from the IL.  */
> +      tree lhs = gimple_call_lhs (stmt);
> +      new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs)));
> +      set_vinfo_for_stmt (new_stmt, stmt_info);
> +      set_vinfo_for_stmt (stmt, NULL);
> +      STMT_VINFO_STMT (stmt_info) = new_stmt;
> +      gsi_replace (gsi, new_stmt, true);
>        return true;
>      }
>    else if (is_store)
> @@ -2149,6 +2158,18 @@ vectorizable_mask_load_store (gimple stm
>  	}
>      }
>  
> +  if (!is_store)
> +    {
> +      /* Ensure that even with -fno-tree-dce the scalar MASK_LOAD is removed
> +	 from the IL.  */
> +      tree lhs = gimple_call_lhs (stmt);
> +      new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs)));
> +      set_vinfo_for_stmt (new_stmt, stmt_info);
> +      set_vinfo_for_stmt (stmt, NULL);
> +      STMT_VINFO_STMT (stmt_info) = new_stmt;
> +      gsi_replace (gsi, new_stmt, true);
> +    }
> +
>    return true;
>  }
>  
> --- gcc/testsuite/g++.dg/vect/pr60559.cc.jj	2014-03-18 14:04:55.173449250 +0100
> +++ gcc/testsuite/g++.dg/vect/pr60559.cc	2014-03-18 14:05:26.610273088 +0100
> @@ -0,0 +1,8 @@
> +// PR tree-optimization/60559
> +// { dg-do compile }
> +// { dg-additional-options "-O3 -std=c++11 -fnon-call-exceptions -fno-tree-dce" }
> +// { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } }
> +
> +#include "pr60023.cc"
> +
> +// { dg-final { cleanup-tree-dump "vect" } }
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer



More information about the Gcc-patches mailing list