diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-07 11:26:58 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-07 11:26:58 +0000 |
commit | 75aefb7b56c1446011ec0faa27ce32b61dd20511 (patch) | |
tree | 91a77a6eacde49e871b7513dea7db0186678681a /gcc/double-int.c | |
parent | 587a19f1d7632728aea48f6b365cc38271b1954b (diff) | |
download | gcc-75aefb7b56c1446011ec0faa27ce32b61dd20511.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198676 138bc75d-0d04-0410-961f-82ee72b054a4
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 b098f57b65c..fe3c096619a 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. */ |