From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7806) id 194603858D33; Sun, 15 Oct 2023 09:20:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 194603858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697361639; bh=Q0L51tEciG6W3sDb7mGuZzTK5LWx91slA3ip9kDD6no=; h=From:To:Subject:Date:From; b=duRn1NeNfi07u+Nnp4+N/y5bY8YVGKWUENR1wszSIO2+JJxyY/UCuflzteGOZst0t foPxyURPcagdJFVRvF9f7qcmaBGnwCSuWMZ/NYoiSOaxjz5w98bnqymYKcwmFExkSV IqEuBc2VF4WPw6QHE9i100YEwLY7n3cE0/rwaWaM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Stefan Schulze Frielinghaus To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4643] combine: Fix handling of unsigned constants X-Act-Checkin: gcc X-Git-Author: Stefan Schulze Frielinghaus X-Git-Refname: refs/heads/master X-Git-Oldrev: 77faa3e198a6b6f9a55a8010bef1c394d2e3cf8e X-Git-Newrev: 648d30716d0cdb5dec96b2da9ed23328bad7cb9f Message-Id: <20231015092039.194603858D33@sourceware.org> Date: Sun, 15 Oct 2023 09:20:39 +0000 (GMT) List-Id: https://gcc.gnu.org/g:648d30716d0cdb5dec96b2da9ed23328bad7cb9f commit r14-4643-g648d30716d0cdb5dec96b2da9ed23328bad7cb9f Author: Stefan Schulze Frielinghaus Date: Sun Oct 15 11:20:01 2023 +0200 combine: Fix handling of unsigned constants If a CONST_INT represents an integer of a mode with fewer bits than in HOST_WIDE_INT, then the integer is sign extended. For those two optimizations touched by this patch, the integers of interest have only the most significant bit set w.r.t their mode, therefore, they were sign extended. Thus in order to get the integer of interest, we have to chop off the high bits. gcc/ChangeLog: * combine.cc (simplify_compare_const): Fix handling of unsigned constants. Diff: --- gcc/combine.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/combine.cc b/gcc/combine.cc index 360aa2f25e6..cb48e7f5b97 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -11923,7 +11923,7 @@ simplify_compare_const (enum rtx_code code, machine_mode mode, /* (unsigned) < 0x80000000 is equivalent to >= 0. */ else if (is_a (mode, &int_mode) && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT - && ((unsigned HOST_WIDE_INT) const_op + && (((unsigned HOST_WIDE_INT) const_op & GET_MODE_MASK (int_mode)) == HOST_WIDE_INT_1U << (GET_MODE_PRECISION (int_mode) - 1))) { const_op = 0; @@ -11962,7 +11962,7 @@ simplify_compare_const (enum rtx_code code, machine_mode mode, /* (unsigned) >= 0x80000000 is equivalent to < 0. */ else if (is_a (mode, &int_mode) && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT - && ((unsigned HOST_WIDE_INT) const_op + && (((unsigned HOST_WIDE_INT) const_op & GET_MODE_MASK (int_mode)) == HOST_WIDE_INT_1U << (GET_MODE_PRECISION (int_mode) - 1))) { const_op = 0;