diff mbox

Fix vect_recog_widen_mult_pattern (PR tree-optimization/57537)

Message ID 20130612092611.GP2336@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek June 12, 2013, 9:26 a.m. UTC
Hi!

gcc.dg/vect/slp-widen-mult-half.c fails on ppc64, because
vect_recog_widen_mult_pattern creates with WIDEN_MULT_EXPR
with invalid argument types - it is a HIxHI->SI multiplication,
and rhs1 is properly HImode, but rhs2 is INTEGER_CST with SImode
(which vect_handle_widen_op_by_const verified it fits into HImode).
As the type is incompatible with what it should have been, when vectorizing
it we actually create a VIEW_CONVERT_EXPR of the SImode INTEGER_CST
to HImode, on little endian that magically works correctly, on big endian
we end up with a vector of zeros rather than vector of the desired
multipliers.  Fixed thusly, so far bootstrapped on i686-linux,
regtest there plus bootstraps/regtests on x86_64-linux, powerpc{,64}-linux
and s390{,x}-linux still pending, ok for trunk/4.8 if it succeeds?

2013-06-12  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/57537
	* tree-vect-patterns.c (vect_recog_widen_mult_pattern): If
	vect_handle_widen_op_by_const, convert oprnd1 to half_type1.


	Jakub

Comments

Richard Biener June 12, 2013, 9:38 a.m. UTC | #1
On Wed, 12 Jun 2013, Jakub Jelinek wrote:

> Hi!
> 
> gcc.dg/vect/slp-widen-mult-half.c fails on ppc64, because
> vect_recog_widen_mult_pattern creates with WIDEN_MULT_EXPR
> with invalid argument types - it is a HIxHI->SI multiplication,
> and rhs1 is properly HImode, but rhs2 is INTEGER_CST with SImode
> (which vect_handle_widen_op_by_const verified it fits into HImode).
> As the type is incompatible with what it should have been, when vectorizing
> it we actually create a VIEW_CONVERT_EXPR of the SImode INTEGER_CST
> to HImode, on little endian that magically works correctly, on big endian
> we end up with a vector of zeros rather than vector of the desired
> multipliers.  Fixed thusly, so far bootstrapped on i686-linux,
> regtest there plus bootstraps/regtests on x86_64-linux, powerpc{,64}-linux
> and s390{,x}-linux still pending, ok for trunk/4.8 if it succeeds?

Ok.

Thanks,
Richard.

> 2013-06-12  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/57537
> 	* tree-vect-patterns.c (vect_recog_widen_mult_pattern): If
> 	vect_handle_widen_op_by_const, convert oprnd1 to half_type1.
> 
> --- gcc/tree-vect-patterns.c.jj	2013-05-17 10:53:10.000000000 +0200
> +++ gcc/tree-vect-patterns.c	2013-06-12 09:49:30.151854270 +0200
> @@ -640,7 +640,10 @@ vect_recog_widen_mult_pattern (vec<gimpl
>            && vect_handle_widen_op_by_const (last_stmt, MULT_EXPR, oprnd1,
>  		                            &oprnd0, stmts, type,
>  					    &half_type0, def_stmt0))
> -        half_type1 = half_type0;
> +	{
> +	  half_type1 = half_type0;
> +	  oprnd1 = fold_convert (half_type1, oprnd1);
> +	}
>        else
>          return NULL;
>      }
> 
> 	Jakub
> 
>
diff mbox

Patch

--- gcc/tree-vect-patterns.c.jj	2013-05-17 10:53:10.000000000 +0200
+++ gcc/tree-vect-patterns.c	2013-06-12 09:49:30.151854270 +0200
@@ -640,7 +640,10 @@  vect_recog_widen_mult_pattern (vec<gimpl
           && vect_handle_widen_op_by_const (last_stmt, MULT_EXPR, oprnd1,
 		                            &oprnd0, stmts, type,
 					    &half_type0, def_stmt0))
-        half_type1 = half_type0;
+	{
+	  half_type1 = half_type0;
+	  oprnd1 = fold_convert (half_type1, oprnd1);
+	}
       else
         return NULL;
     }