comparison gcc/hwint.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Operations on HOST_WIDE_INT. 1 /* Operations on HOST_WIDE_INT.
2 Copyright (C) 1987-2017 Free Software Foundation, Inc. 2 Copyright (C) 1987-2018 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it under 6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free 7 the terms of the GNU General Public License as published by the Free
58 t += 1; 58 t += 1;
59 59
60 return t; 60 return t;
61 } 61 }
62 62
63 /* Given X, an unsigned number, return the largest Y such that 2**Y >= X. */ 63 /* Given X, an unsigned number, return the least Y such that 2**Y >= X. */
64 64
65 int 65 int
66 ceil_log2 (unsigned HOST_WIDE_INT x) 66 ceil_log2 (unsigned HOST_WIDE_INT x)
67 { 67 {
68 return floor_log2 (x - 1) + 1; 68 return x == 0 ? 0 : floor_log2 (x - 1) + 1;
69 } 69 }
70 70
71 /* Return the logarithm of X, base 2, considering X unsigned, 71 /* Return the logarithm of X, base 2, considering X unsigned,
72 if X is a power of 2. Otherwise, returns -1. */ 72 if X is a power of 2. Otherwise, returns -1. */
73 73