Commit 3fed2ce9 by Richard Sandiford Committed by Richard Sandiford

poly_int: find_bswap_or_nop_load

This patch handles polynomial offsets in find_bswap_or_nop_load,
which could be useful for constant-sized data at a variable offset.
It is needed for a later patch to compile.

2017-12-21  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* gimple-ssa-stor-merging.c (find_bswap_or_nop_load): Track polynomial
	offsets for MEM_REFs.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r255929
parent bc83d568
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* gimple-ssa-stor-merging.c (find_bswap_or_nop_load): Track polynomial
offsets for MEM_REFs.
2017-12-21 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* tree-ssanames.h (adjust_ptr_info_misalignment): Take the increment * tree-ssanames.h (adjust_ptr_info_misalignment): Take the increment
as a poly_uint64 rather than an unsigned int. as a poly_uint64 rather than an unsigned int.
* tree-ssanames.c (adjust_ptr_info_misalignment): Likewise. * tree-ssanames.c (adjust_ptr_info_misalignment): Likewise.
...@@ -374,35 +374,31 @@ find_bswap_or_nop_load (gimple *stmt, tree ref, struct symbolic_number *n) ...@@ -374,35 +374,31 @@ find_bswap_or_nop_load (gimple *stmt, tree ref, struct symbolic_number *n)
return false; return false;
else if (TREE_CODE (base_addr) == MEM_REF) else if (TREE_CODE (base_addr) == MEM_REF)
{ {
offset_int bit_offset = 0; poly_offset_int bit_offset = 0;
tree off = TREE_OPERAND (base_addr, 1); tree off = TREE_OPERAND (base_addr, 1);
if (!integer_zerop (off)) if (!integer_zerop (off))
{ {
offset_int boff, coff = mem_ref_offset (base_addr); poly_offset_int boff = mem_ref_offset (base_addr);
boff = coff << LOG2_BITS_PER_UNIT; boff <<= LOG2_BITS_PER_UNIT;
bit_offset += boff; bit_offset += boff;
} }
base_addr = TREE_OPERAND (base_addr, 0); base_addr = TREE_OPERAND (base_addr, 0);
/* Avoid returning a negative bitpos as this may wreak havoc later. */ /* Avoid returning a negative bitpos as this may wreak havoc later. */
if (wi::neg_p (bit_offset)) if (maybe_lt (bit_offset, 0))
{ {
offset_int mask = wi::mask <offset_int> (LOG2_BITS_PER_UNIT, false); tree byte_offset = wide_int_to_tree
offset_int tem = wi::bit_and_not (bit_offset, mask); (sizetype, bits_to_bytes_round_down (bit_offset));
/* TEM is the bitpos rounded to BITS_PER_UNIT towards -Inf. bit_offset = num_trailing_bits (bit_offset);
Subtract it to BIT_OFFSET and add it (scaled) to OFFSET. */
bit_offset -= tem;
tem >>= LOG2_BITS_PER_UNIT;
if (offset) if (offset)
offset = size_binop (PLUS_EXPR, offset, offset = size_binop (PLUS_EXPR, offset, byte_offset);
wide_int_to_tree (sizetype, tem));
else else
offset = wide_int_to_tree (sizetype, tem); offset = byte_offset;
} }
bitpos += bit_offset.to_shwi (); bitpos += bit_offset.force_shwi ();
} }
else else
base_addr = build_fold_addr_expr (base_addr); base_addr = build_fold_addr_expr (base_addr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment