From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 4499238515C3; Tue, 11 Oct 2022 13:04:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4499238515C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665493479; bh=4UrWMHb9o1t7QrD1xdH5RN34BzdkAE2EhOuKdjvWwfc=; h=From:To:Subject:Date:From; b=fnvUalr2p+1BxmLWF3iW6qPuQhkuULWygWtCid1dCqDb1BowDHVMh7EF+e5vFMC4F Hh2CRQfXFWKWrPBnxoHVtgOQ8C/yKMKs5GnuuXu0K9L1NEKV4GSOFk40ojIJOxeSXg 617LnC/8wSYgcGR7qPTWJAtB7ETHeWNSYRuLbdaQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-10306] tree-optimization/106513 - fix mistake in bswap symbolic number shifts X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 90d3b4dd84c08cc134578397d9c6b30b7dc4b440 X-Git-Newrev: ec718fb7a3a58955017cd80f6a8927afbe340fc4 Message-Id: <20221011130439.4499238515C3@sourceware.org> Date: Tue, 11 Oct 2022 13:04:39 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ec718fb7a3a58955017cd80f6a8927afbe340fc4 commit r11-10306-gec718fb7a3a58955017cd80f6a8927afbe340fc4 Author: Richard Biener Date: Wed Aug 10 15:45:22 2022 +0200 tree-optimization/106513 - fix mistake in bswap symbolic number shifts This fixes a mistake in typing a local variable in the symbolic shift routine. PR tree-optimization/106513 * gimple-ssa-store-merging.c (do_shift_rotate): Use uint64_t for head_marker. * gcc.dg/torture/pr106513.c: New testcase. (cherry picked from commit f675afa4eeac9910a2c085a95aa04d6d9f2fd8d6) Diff: --- gcc/gimple-ssa-store-merging.c | 2 +- gcc/testsuite/gcc.dg/torture/pr106513.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c index 0a74b025d00..6c1b8cdb487 100644 --- a/gcc/gimple-ssa-store-merging.c +++ b/gcc/gimple-ssa-store-merging.c @@ -263,7 +263,7 @@ do_shift_rotate (enum tree_code code, int count) { int i, size = TYPE_PRECISION (n->type) / BITS_PER_UNIT; - unsigned head_marker; + uint64_t head_marker; if (count < 0 || count >= TYPE_PRECISION (n->type) diff --git a/gcc/testsuite/gcc.dg/torture/pr106513.c b/gcc/testsuite/gcc.dg/torture/pr106513.c new file mode 100644 index 00000000000..aa4f4d513d7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr106513.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ + +typedef __INT64_TYPE__ int64_t; + +__attribute__((noinline)) int64_t +swap64 (int64_t n) +{ + return (((n & (((int64_t) 0xff) )) << 56) | + ((n & (((int64_t) 0xff) << 8)) << 40) | + ((n & (((int64_t) 0xff) << 16)) << 24) | + ((n & (((int64_t) 0xff) << 24)) << 8) | + ((n & (((int64_t) 0xff) << 32)) >> 8) | + ((n & (((int64_t) 0xff) << 40)) >> 24) | + ((n & (((int64_t) 0xff) << 48)) >> 40) | + ((n & ((int64_t)(0xffull << 56))) >> 56)); +} + +int main (void) +{ + volatile int64_t n = 0x8000000000000000ll; + + if (swap64(n) != 0xffffffffffffff80ll) + __builtin_abort (); + + return 0; +}