diff mbox

wide-int, rs6000

Message ID 7CA46FBB-DFDB-40FB-B130-81621A22EC39@comcast.net
State New
Headers show

Commit Message

Mike Stump Nov. 26, 2013, 3:05 a.m. UTC
On Nov 25, 2013, at 12:03 PM, David Edelsohn <dje.gcc@gmail.com> wrote:
> 3) altivec_resolve_overloaded_builtin, both hunks should be converted
> the same way, using tree_fits_uhwi_p
> 
> -   && TREE_CODE (arg2) == INTEGER_CST
> -   && TREE_INT_CST_HIGH (arg2) == 0
> -   && (TREE_INT_CST_LOW (arg2) == 0 || TREE_INT_CST_LOW (arg2) == 1))
> +   && tree_fits_uhwi_p (arg2)
> +   && wi::ltu_p (arg2, 2))

Comments

Richard Sandiford Nov. 26, 2013, 11:58 a.m. UTC | #1
Mike Stump <mikestump@comcast.net> writes:
> On Nov 25, 2013, at 12:03 PM, David Edelsohn <dje.gcc@gmail.com> wrote:
>> 3) altivec_resolve_overloaded_builtin, both hunks should be converted
>> the same way, using tree_fits_uhwi_p
>> 
>> -   && TREE_CODE (arg2) == INTEGER_CST
>> -   && TREE_INT_CST_HIGH (arg2) == 0
>> -   && (TREE_INT_CST_LOW (arg2) == 0 || TREE_INT_CST_LOW (arg2) == 1))
>> +   && tree_fits_uhwi_p (arg2)
>> +   && wi::ltu_p (arg2, 2))
>
> Index: gcc/config/rs6000/rs6000-c.c
> ===================================================================
> --- gcc/config/rs6000/rs6000-c.c	(revision 205364)
> +++ gcc/config/rs6000/rs6000-c.c	(working copy)
> @@ -4208,7 +4208,7 @@ altivec_resolve_overloaded_builtin (loca
>        /* If we can use the VSX xxpermdi instruction, use that for extract.  */
>        mode = TYPE_MODE (arg1_type);
>        if ((mode == V2DFmode || mode == V2DImode) && VECTOR_MEM_VSX_P (mode)
> -	  && TREE_CODE (arg2) == INTEGER_CST
> +	  && tree_fits_uhwi_p (arg2)
>  	  && wi::ltu_p (arg2, 2))
>  	{
>  	  tree call = NULL_TREE;

Hmm, I think the original was correct here, since there's no reason to rely
on HWIness for an unsigned comparison with 2.  It also ought to be more
efficient.

I'd rather change the other case to have an INTEGER_CST test too.

Thanks,
Richard
diff mbox

Patch

Index: gcc/config/rs6000/rs6000-c.c
===================================================================
--- gcc/config/rs6000/rs6000-c.c	(revision 205364)
+++ gcc/config/rs6000/rs6000-c.c	(working copy)
@@ -4208,7 +4208,7 @@  altivec_resolve_overloaded_builtin (loca
       /* If we can use the VSX xxpermdi instruction, use that for extract.  */
       mode = TYPE_MODE (arg1_type);
       if ((mode == V2DFmode || mode == V2DImode) && VECTOR_MEM_VSX_P (mode)
-	  && TREE_CODE (arg2) == INTEGER_CST
+	  && tree_fits_uhwi_p (arg2)
 	  && wi::ltu_p (arg2, 2))
 	{
 	  tree call = NULL_TREE;