From d16b48d51064e73ea2141a4eaec1c56c3a6c307c Mon Sep 17 00:00:00 2001 From: nemet Date: Tue, 11 Aug 2009 17:31:09 +0000 Subject: * combine.c (try_widen_shift_mode): Factor out code to check if an integer constant is a low-order bitmask from here ... * rtlanal.c (low_bitmask_len): ... to here. * rtl.h (low_bitmask_len): Declare. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150656 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/rtlanal.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gcc/rtlanal.c') diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 49289b65c37..aebcfa66904 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -5032,3 +5032,20 @@ constant_pool_constant_p (rtx x) x = avoid_constant_pool_reference (x); return GET_CODE (x) == CONST_DOUBLE; } + +/* If M is a bitmask that selects a field of low-order bits within an item but + not the entire word, return the length of the field. Return -1 otherwise. + M is used in machine mode MODE. */ + +int +low_bitmask_len (enum machine_mode mode, unsigned HOST_WIDE_INT m) +{ + if (mode != VOIDmode) + { + if (GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT) + return -1; + m &= GET_MODE_MASK (mode); + } + + return exact_log2 (m + 1); +} -- cgit v1.2.1