diff options
author | Richard Biener <rguenther@suse.de> | 2013-05-07 11:26:58 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2013-05-07 11:26:58 +0000 |
commit | 39e843e8a7a15d93c6a23ec007e70738505291b3 (patch) | |
tree | 91a77a6eacde49e871b7513dea7db0186678681a /gcc/double-int.c | |
parent | 0a1a83cba32006411c4ce4793ca516406489cfae (diff) | |
download | gcc-39e843e8a7a15d93c6a23ec007e70738505291b3.zip gcc-39e843e8a7a15d93c6a23ec007e70738505291b3.tar.gz gcc-39e843e8a7a15d93c6a23ec007e70738505291b3.tar.bz2 |
double-int.h (rshift): New overload.
2013-05-07 Richard Biener <rguenther@suse.de>
* double-int.h (rshift): New overload.
* double-int.c (rshift): New function.
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Optimize.
(create_reference_ops_from_ref): Remove.
(vn_reference_insert): Use shared ops for constructing the
reference and copy it.
From-SVN: r198676
Diffstat (limited to 'gcc/double-int.c')
-rw-r--r-- | gcc/double-int.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/double-int.c b/gcc/double-int.c index b098f57..fe3c096 100644 --- a/gcc/double-int.c +++ b/gcc/double-int.c @@ -1116,6 +1116,39 @@ double_int::lshift (HOST_WIDE_INT count) const return ret; } +/* Shift A right by COUNT places. */ + +double_int +double_int::rshift (HOST_WIDE_INT count) const +{ + double_int ret; + + gcc_checking_assert (count >= 0); + + if (count >= HOST_BITS_PER_DOUBLE_INT) + { + /* Shifting by the host word size is undefined according to the + ANSI standard, so we must handle this as a special case. */ + ret.high = 0; + ret.low = 0; + } + else if (count >= HOST_BITS_PER_WIDE_INT) + { + ret.high = 0; + ret.low + = (unsigned HOST_WIDE_INT) (high >> (count - HOST_BITS_PER_WIDE_INT)); + } + else + { + ret.high = high >> count; + ret.low = ((low >> count) + | ((unsigned HOST_WIDE_INT) high + << (HOST_BITS_PER_WIDE_INT - count - 1) << 1)); + } + + return ret; +} + /* Shift A left by COUNT places keeping only PREC bits of result. Shift right if COUNT is negative. ARITH true specifies arithmetic shifting; otherwise use logical shift. */ |