From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8B7E13858C2F; Fri, 5 Aug 2022 22:15:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B7E13858C2F From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106513] [10/11/12/13 Regression] bswap pass misses that >>56 for signed types can be replicate the sign bit Date: Fri, 05 Aug 2022 22:15:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed cf_known_to_fail short_desc cf_known_to_work target_milestone bug_status cf_reconfirmed_on Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2022 22:15:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106513 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Known to fail| |4.5.3, 4.6.4 Summary|bswap is incorrectly |[10/11/12/13 Regression] |generated |bswap pass misses that >>56 | |for signed types can be | |replicate the sign bit Known to work| |4.4.7 Target Milestone|--- |10.5 Status|UNCONFIRMED |NEW Last reconfirmed| |2022-08-05 --- Comment #3 from Andrew Pinski --- Confirmed. Better testcase (without the questionable undefined behavior): typedef long long int 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 =3D 0x8000000000000000l; if (swap64(n) !=3D 0xffffffffffffff80l) __builtin_abort (); return 0; }=