diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-05-02 09:39:38 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-05-02 09:39:38 +0000 |
commit | 9fdc1ed465b17ebbf09f420016ba5969581964fd (patch) | |
tree | ea2f8d60c73117cebcd97dfbc56bb80d7c4ee632 /gcc/expr.c | |
parent | 32115eac18b917f7b7a093bac1f93e6ce73e6065 (diff) | |
download | gcc-9fdc1ed465b17ebbf09f420016ba5969581964fd.tar.gz |
Support << and >> for offset_int and widest_int
Following on from the comparison patch, I think it makes sense to
support << and >> for offset_int (int128_t) and widest_int (intNNN_t),
with >> being arithmetic shift. It doesn't make sense to use
logical right shift on a potentially negative offset_int, since
the precision of 128 bits has no meaning on the target.
Tested on x86_64-linux-gnu and aarch64-linux-gnu.
gcc/
* wide-int.h: Update offset_int and widest_int documentation.
(WI_SIGNED_SHIFT_RESULT): New macro.
(wi::binary_shift): Define signed_shift_result_type for
shifts on offset_int- and widest_int-like types.
(generic_wide_int): Support <<= and >>= if << and >> are supported.
* tree.h (int_bit_position): Use shift operators instead of wi::
shifts.
* alias.c (adjust_offset_for_component_ref): Likewise.
* expr.c (get_inner_reference): Likewise.
* fold-const.c (fold_comparison): Likewise.
* gimple-fold.c (fold_nonarray_ctor_reference): Likewise.
* gimple-ssa-strength-reduction.c (restructure_reference): Likewise.
* tree-dfa.c (get_ref_base_and_extent): Likewise.
* tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Likewise.
(stmt_kills_ref_p): Likewise.
* tree-ssa-ccp.c (bit_value_binop_1): Likewise.
* tree-ssa-math-opts.c (find_bswap_or_nop_load): Likewise.
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Likewise.
(ao_ref_init_from_vn_reference): Likewise.
gcc/cp/
* init.c (build_new_1): Use shift operators instead of wi:: shifts.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235720 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/expr.c b/gcc/expr.c index 248d3d7bf82..8870a0c9872 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6989,7 +6989,7 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize, if (!integer_zerop (off)) { offset_int boff, coff = mem_ref_offset (exp); - boff = wi::lshift (coff, LOG2_BITS_PER_UNIT); + boff = coff << LOG2_BITS_PER_UNIT; bit_offset += boff; } exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); @@ -7015,7 +7015,7 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize, { offset_int tem = wi::sext (wi::to_offset (offset), TYPE_PRECISION (sizetype)); - tem = wi::lshift (tem, LOG2_BITS_PER_UNIT); + tem <<= LOG2_BITS_PER_UNIT; tem += bit_offset; if (wi::fits_shwi_p (tem)) { @@ -7035,7 +7035,7 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize, /* TEM is the bitpos rounded to BITS_PER_UNIT towards -Inf. Subtract it to BIT_OFFSET and add it (scaled) to OFFSET. */ bit_offset -= tem; - tem = wi::arshift (tem, LOG2_BITS_PER_UNIT); + tem >>= LOG2_BITS_PER_UNIT; offset = size_binop (PLUS_EXPR, offset, wide_int_to_tree (sizetype, tem)); } |