From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 86B6C395181A; Wed, 23 Sep 2020 23:23:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86B6C395181A Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] adjust shiftrt bitpos for endianness X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: de4bb02889b888a7a99758ef63f08fbb9d2d57de X-Git-Newrev: 118e7820efa48cf141be3b750ba10ea042e69025 Message-Id: <20200923232345.86B6C395181A@sourceware.org> Date: Wed, 23 Sep 2020 23:23:45 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2020 23:23:45 -0000 https://gcc.gnu.org/g:118e7820efa48cf141be3b750ba10ea042e69025 commit 118e7820efa48cf141be3b750ba10ea042e69025 Author: Alexandre Oliva 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 081c41f7fbe..e39ab42049e 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 (!*preversep ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN) + *pbitpos += shiftrt; *pbitsize -= shiftrt; }