From 05ff4c5fa71037322916d2936dce3f762357c647 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 2 May 2016 09:40:32 +0000 Subject: [PATCH] Simplify cst_and_fits_in_hwi 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. gcc/ * tree.c (cst_and_fits_in_hwi): Simplify. From-SVN: r235722 --- gcc/ChangeLog | 4 ++++ gcc/tree.c | 9 ++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7b1c8389cada..7ea67aaf2ae6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2016-05-02 Richard Sandiford + + * tree.c (cst_and_fits_in_hwi): Simplify. + 2016-05-02 Richard Sandiford * tree.h (wi::to_wide): New function. diff --git a/gcc/tree.c b/gcc/tree.c index 8ec2d5c146c1..f7366f634024 100644 --- a/gcc/tree.c +++ b/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. */ -- 2.47.2