From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 474A33858C39; Thu, 13 Oct 2022 16:54:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 474A33858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665680098; bh=1o311OC8jtSqxJ66A2SQ11XaYx9jtDItKD3fVqKJJ/s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ipq4pUpULHCm4wVOAcCWz9Lt55AZylCAge/+sB76u+TY6NlRALRutP3CkFsyLrlhl Ert96bAORgVGT+El6bHuxP7Fc4PF7WBGSgr3IngpBXcPv1nYLBvxJxS1NihG5RMYYe aGRHosxUDWRjSFh+OwU0EdvGv8h++JAGNhKMfLh0= From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/107172] [13 Regression] wrong code with "-O1 -ftree-vrp" on x86_64-linux-gnu since r13-1268-g8c99e307b20c502e Date: Thu, 13 Oct 2022 16:54:47 +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.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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=3D107172 --- Comment #26 from H.J. Lu --- (In reply to Uro=C5=A1 Bizjak from comment #24) > (In reply to Hongtao.liu from comment #23) > > looking at i386.c put_condition_code used by *setcc_qi, it looks like (= EQ > > (reg:CCCmode FLAG_REG) (const_int 0)) means get carry flag. > > Not (LTU: (REG:CCCmode FLAGS_REG) (const_int 0)). > > Now I got more confused. >=20 > CCCmode means that single flag is tested, it uses EQ and NE, so "c" and "= nc" > suffix is emitted. When CCmode is used, LTU/GEU operation on CCmode flags > reg produces "b" and "nb" suffix, which decodes to exactly the same assem= bly > as "c" and "nc" suffixes. >=20 > However, it looks that somewhere LTU/GEU is also generated with CCCmode > flags reg, and some fixup was introduced to put_condition_code to "fix" t= his > inconsistency. If LTU/GEU is valid only for CCmode, then the producers of > invalid RTX should be fixed. EQ and NE are only used to set FLAGS_REG in CCCmode from 2 integer operands. LTU/GEU are only used to check FLAGS_REG against constant 0. This is very consistent. simplify_const_relational_operation has /* We can't simplify MODE_CC values since we don't know what the actual comparison is. */ if (GET_MODE_CLASS (GET_MODE (op0)) =3D=3D MODE_CC) return 0; In case of the comparison in CCCmode with constant op0 and op1, it should let the backend perform the actual comparison.=