[gcc(refs/users/aoliva/heads/testme)] adjust shiftrt bitpos for endianness

Alexandre Oliva aoliva@gcc.gnu.org
Thu Sep 17 11:31:49 GMT 2020


https://gcc.gnu.org/g:4e39482a9cbd43e6e2da4035c25d573ab267e12d

commit 4e39482a9cbd43e6e2da4035c25d573ab267e12d
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Thu Sep 17 08:29:24 2020 -0300

    adjust shiftrt bitpos for endianness

Diff:
---
 gcc/fold-const.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index c835327dac9..3f8f54a7f49 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -4686,7 +4686,7 @@ decode_field_reference (location_t loc, tree *exp_, HOST_WIDE_INT *pbitsize,
   if ((inner == exp && and_mask == 0)
       || !poly_bitsize.is_constant (pbitsize)
       || !poly_bitpos.is_constant (pbitpos)
-      || *pbitsize < shiftrt
+      || *pbitsize <= shiftrt
       || offset != 0
       || TREE_CODE (inner) == PLACEHOLDER_EXPR
       /* Reject out-of-bound accesses (PR79731).  */
@@ -4697,7 +4697,8 @@ decode_field_reference (location_t loc, tree *exp_, HOST_WIDE_INT *pbitsize,
 
   if (shiftrt)
     {
-      *pbitpos += shiftrt;
+      if (!lr_reversep ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN)
+	*pbitpos += shiftrt;
       *pbitsize -= shiftrt;
     }


More information about the Gcc-cvs mailing list