From 68a8632380e3606aeea2eb11921461e24926dddc Mon Sep 17 00:00:00 2001 From: Kyrylo Tkachov Date: Fri, 24 Jun 2016 12:46:19 +0000 Subject: [PATCH] [ARM][1/4] Replace uses of int_log2 by exact_log2 * config/arm/arm.c (int_log2): Delete definition and prototype. (shift_op): Use exact_log2 instead of int_log2. (vfp3_const_double_for_fract_bits): Likewise. From-SVN: r237757 --- gcc/ChangeLog | 6 ++++++ gcc/config/arm/arm.c | 26 +++++++------------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fdc489833f7..2c55cb3f0bc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-06-24 Kyrylo Tkachov + + * config/arm/arm.c (int_log2): Delete definition and prototype. + (shift_op): Use exact_log2 instead of int_log2. + (vfp3_const_double_for_fract_bits): Likewise. + 2016-06-24 Jakub Jelinek * internal-fn.c (expand_arith_set_overflow): New function. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index a7dda1f53ca..f60955438d6 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -104,7 +104,6 @@ static void arm_print_operand_address (FILE *, machine_mode, rtx); static bool arm_print_operand_punct_valid_p (unsigned char code); static const char *fp_const_from_val (REAL_VALUE_TYPE *); static arm_cc get_arm_condition_code (rtx); -static HOST_WIDE_INT int_log2 (HOST_WIDE_INT); static const char *output_multi_immediate (rtx *, const char *, const char *, int, HOST_WIDE_INT); static const char *shift_op (rtx, HOST_WIDE_INT *); @@ -19094,7 +19093,8 @@ shift_op (rtx op, HOST_WIDE_INT *amountp) return NULL; } - *amountp = int_log2 (*amountp); + *amountp = exact_log2 (*amountp); + gcc_assert (IN_RANGE (*amountp, 0, 31)); return ARM_LSL_NAME; default: @@ -19126,22 +19126,6 @@ shift_op (rtx op, HOST_WIDE_INT *amountp) return mnem; } -/* Obtain the shift from the POWER of two. */ - -static HOST_WIDE_INT -int_log2 (HOST_WIDE_INT power) -{ - HOST_WIDE_INT shift = 0; - - while ((((HOST_WIDE_INT) 1 << shift) & power) == 0) - { - gcc_assert (shift <= 31); - shift++; - } - - return shift; -} - /* Output a .ascii pseudo-op, keeping track of lengths. This is because /bin/as is horribly restrictive. The judgement about whether or not each character is 'printable' (and can be output as @@ -27931,7 +27915,11 @@ vfp3_const_double_for_fract_bits (rtx operand) HOST_WIDE_INT value = real_to_integer (&r0); value = value & 0xffffffff; if ((value != 0) && ( (value & (value - 1)) == 0)) - return int_log2 (value); + { + int ret = exact_log2 (value); + gcc_assert (IN_RANGE (ret, 0, 31)); + return ret; + } } } return 0; -- 2.30.2