aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-store-merging.c
diff options
context:
space:
mode:
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>2016-11-02 09:28:35 +0000
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>2016-11-02 09:28:35 +0000
commit4b2c06f49f8d7365e2aa15f32cbc6a726c9ff9fb (patch)
tree8f619725f7d1a2f96ab4e48798bf97f9f0d98f89 /gcc/gimple-ssa-store-merging.c
parent63e523d6f0853765adc332c7a68a8e6b16971d6b (diff)
downloadgcc-4b2c06f49f8d7365e2aa15f32cbc6a726c9ff9fb.zip
gcc-4b2c06f49f8d7365e2aa15f32cbc6a726c9ff9fb.tar.gz
gcc-4b2c06f49f8d7365e2aa15f32cbc6a726c9ff9fb.tar.bz2
PR tree-optimization/78170: Truncate sign-extended padding when encoding bitfields
PR tree-optimization/78170 * gimple-ssa-store-merging.c (encode_tree_to_bitpos): Truncate padding introduced by native_encode_expr on little-endian as well. * gcc.c-torture/execute/pr78170.c: New test. From-SVN: r241779
Diffstat (limited to 'gcc/gimple-ssa-store-merging.c')
-rw-r--r--gcc/gimple-ssa-store-merging.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
index feba907..f279511 100644
--- a/gcc/gimple-ssa-store-merging.c
+++ b/gcc/gimple-ssa-store-merging.c
@@ -432,13 +432,23 @@ encode_tree_to_bitpos (tree expr, unsigned char *ptr, int bitlen, int bitpos,
contain a sign bit due to sign-extension). */
unsigned int padding
= byte_size - ROUND_UP (bitlen, BITS_PER_UNIT) / BITS_PER_UNIT - 1;
- if (BYTES_BIG_ENDIAN)
+ if (padding != 0)
{
- tmpbuf += padding;
+ /* On big-endian the padding is at the 'front' so just skip the initial
+ bytes. */
+ if (BYTES_BIG_ENDIAN)
+ tmpbuf += padding;
+
byte_size -= padding;
if (bitlen % BITS_PER_UNIT != 0)
- clear_bit_region_be (tmpbuf, BITS_PER_UNIT - 1,
- BITS_PER_UNIT - (bitlen % BITS_PER_UNIT));
+ {
+ if (BYTES_BIG_ENDIAN)
+ clear_bit_region_be (tmpbuf, BITS_PER_UNIT - 1,
+ BITS_PER_UNIT - (bitlen % BITS_PER_UNIT));
+ else
+ clear_bit_region (tmpbuf, bitlen,
+ byte_size * BITS_PER_UNIT - bitlen);
+ }
}
/* Clear the bit region in PTR where the bits from TMPBUF will be