diff mbox

Simplify cst_and_fits_in_hwi

Message ID 87d1p8fvat.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford April 29, 2016, 12:34 p.m. UTC
While looking at the use of cst_and_fits_in_hwi in tree-ssa-loop-ivopts.c,
I had difficulty working out what the function actually tests.  The
final NUNITS check seems redundant, since it asks about the number of
HWIs in the _unextended_ constant.  We've already checked that the
unextended constant has no more than HOST_BITS_PER_WIDE_INT bits, so the
length must be 1.

I think this was my fault, sorry.

Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?

Thanks,
Richard


gcc/
	* tree.c (cst_and_fits_in_hwi): Simplify.

Comments

Richard Biener May 2, 2016, 8:51 a.m. UTC | #1
On Fri, Apr 29, 2016 at 2:34 PM, Richard Sandiford
<richard.sandiford@arm.com> wrote:
> While looking at the use of cst_and_fits_in_hwi in tree-ssa-loop-ivopts.c,
> I had difficulty working out what the function actually tests.  The
> final NUNITS check seems redundant, since it asks about the number of
> HWIs in the _unextended_ constant.  We've already checked that the
> unextended constant has no more than HOST_BITS_PER_WIDE_INT bits, so the
> length must be 1.
>
> I think this was my fault, sorry.
>
> Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?

Ok.

Richard.

> Thanks,
> Richard
>
>
> gcc/
>         * tree.c (cst_and_fits_in_hwi): Simplify.
>
> Index: gcc/tree.c
> ===================================================================
> --- gcc/tree.c
> +++ gcc/tree.c
> @@ -1675,13 +1675,8 @@ build_low_bits_mask (tree type, unsigned bits)
>  bool
>  cst_and_fits_in_hwi (const_tree x)
>  {
> -  if (TREE_CODE (x) != INTEGER_CST)
> -    return false;
> -
> -  if (TYPE_PRECISION (TREE_TYPE (x)) > HOST_BITS_PER_WIDE_INT)
> -    return false;
> -
> -  return TREE_INT_CST_NUNITS (x) == 1;
> +  return (TREE_CODE (x) == INTEGER_CST
> +         && TYPE_PRECISION (TREE_TYPE (x)) <= HOST_BITS_PER_WIDE_INT);
>  }
>
>  /* Build a newly constructed VECTOR_CST node of length LEN.  */
diff mbox

Patch

Index: gcc/tree.c
===================================================================
--- gcc/tree.c
+++ gcc/tree.c
@@ -1675,13 +1675,8 @@  build_low_bits_mask (tree type, unsigned bits)
 bool
 cst_and_fits_in_hwi (const_tree x)
 {
-  if (TREE_CODE (x) != INTEGER_CST)
-    return false;
-
-  if (TYPE_PRECISION (TREE_TYPE (x)) > HOST_BITS_PER_WIDE_INT)
-    return false;
-
-  return TREE_INT_CST_NUNITS (x) == 1;
+  return (TREE_CODE (x) == INTEGER_CST
+	  && TYPE_PRECISION (TREE_TYPE (x)) <= HOST_BITS_PER_WIDE_INT);
 }
 
 /* Build a newly constructed VECTOR_CST node of length LEN.  */