From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3F6D93858420; Thu, 11 Apr 2024 06:52:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F6D93858420 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712818369; bh=R1czdUoSUPIcFrptbyvI5Jx3QIJ9cUD9tT4qUFX83CY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tAYtQkX5W8nQK0JUugX6RX4Ypi4LwkjAGVIAvbUHh+ICcKNa7+KSUR6s1Xnh43ngd 7g/d5LSCYbXT/N7ul5XVwBM2d7Sk+mK26ikZc/RxT0wxGTqz+lQ8xTORejZyMfJV7Q /OK+T/KR+aLebro8o9yQioke6vo0YVsnl40Fvkpw= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114130] [11/12/13 Regression] RISC-V: `__atomic_compare_exchange` does not use sign-extended value for RV64 Date: Thu, 11 Apr 2024 06:52:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: kito at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114130 --- Comment #4 from GCC Commits --- The releases/gcc-12 branch has been updated by Kito Cheng : https://gcc.gnu.org/g:d37be5c0413783c5459c5664b6ffb9f47acfca4e commit r12-10319-gd37be5c0413783c5459c5664b6ffb9f47acfca4e Author: Kito Cheng Date: Wed Feb 28 16:01:52 2024 +0800 RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64 atomic_compare_and_swapsi will use lr.w to do obtain the original value, which sign extends to DI. RV64 only has DI comparisons, so we also need to sign extend the expected value to DI as otherwise the comparison will fail when the expected value has the 32nd bit set. gcc/ChangeLog: PR target/114130 * config/riscv/sync.md (atomic_compare_and_swap): Sign extend the expected value if needed. gcc/testsuite/ChangeLog: * gcc.target/riscv/pr114130.c: New. Reviewed-by: Palmer Dabbelt (cherry picked from commit fd07a29e39f5347d6cef3e7042a32306f97a1719)=