From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 464323858CD1; Fri, 14 Jul 2023 10:15:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 464323858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689329731; bh=32rzFxcTbuZqwrHyq1LuBZ1ptcGaMulIoMvx53h3XQc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BMWHX89aKUQb7fOKkdsYQEdBO+AA7YtIucSPxam5EYM4ehtYPGPgoDe3wzdKQ2+xz JUMbXd5MHjQT/Dh0HITdd7QJ0RZc3f1+k0gR2jK+Yq0zhawtEo31HQKJqZD6i8s62S GipWZczo1F/Xvspfsp9imXTL1gPeQIVt5gF26Ado= From: "syq at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/104914] [MIPS] wrong comparison with scrabbled int value Date: Fri, 14 Jul 2023 10:15:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: syq 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: --- 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=3D104914 --- Comment #14 from YunQiang Su --- New patch: diff --git a/gcc/expmed.cc b/gcc/expmed.cc index fbd4ce2d42f..66d45da67df 100644 --- a/gcc/expmed.cc +++ b/gcc/expmed.cc @@ -850,6 +850,7 @@ store_bit_field_1 (rtx str_rtx, poly_uint64 bitsize, poly_uint64 bitnum, since that case is valid for any mode. The following cases are only valid for integral modes. */ opt_scalar_int_mode op0_mode =3D int_mode_for_mode (GET_MODE (op0)); + opt_scalar_int_mode str_mode =3D int_mode_for_mode (GET_MODE (str_rtx)); scalar_int_mode imode; if (!op0_mode.exists (&imode) || imode !=3D GET_MODE (op0)) { @@ -881,8 +882,15 @@ store_bit_field_1 (rtx str_rtx, poly_uint64 bitsize, poly_uint64 bitnum, op0 =3D gen_lowpart (op0_mode.require (), op0); } - return store_integral_bit_field (op0, op0_mode, ibitsize, ibitnum, - bitregion_start, bitregion_end, + bool use_str_mode =3D false; + if (GET_MODE_CLASS(GET_MODE (str_rtx)) =3D=3D MODE_INT + && GET_MODE_CLASS(GET_MODE (op0)) =3D=3D MODE_INT + && known_gt (GET_MODE_SIZE(GET_MODE(op0)), GET_MODE_SIZE(GET_MODE(str_rtx)))) + use_str_mode =3D true; + + return store_integral_bit_field (use_str_mode ? str_rtx : op0, + use_str_mode ? str_mode : op0_mode, + ibitsize, ibitnum, bitregion_start, bitregion_end, fieldmode, value, reverse, fallback_p); }=