From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 801B13858D35; Fri, 9 Jun 2023 23:19:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 801B13858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686352775; bh=w8P5nlDwimrg+LshBVOikGu6tD4NQfxwE6ZflMsc0q0=; h=From:To:Subject:Date:From; b=nRMnYdaG3HlXWR1SDTgR2wGg1yRD6aTxNbikoOnt/KlzbMBKSwgPeQsgl0+h/Vci0 uFOZFZ1ErYp7Zgk1N8bihjNNzqg99zCQEI0aoxjn2H9/xpVH57/TAhV54gr6pSp2dH cbI512eN9fBxxxhs367fJJaXMEjSJk8TXCuZbJw0= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/110200] New: genmatch generating questionable code with convert and ! Date: Fri, 09 Jun 2023 23:19:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: build X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D110200 Bug ID: 110200 Summary: genmatch generating questionable code with convert and ! Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: build Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Add these two patterns to match.pd: ``` /* (convert)(a ? b : CST) -> (a ? (convert)b : CST1) */ (simplify (convert (cond @0 @1 CONSTANT_CLASS_P@2)) (cond @0 (convert @1) (convert! @2))) /* (convert)(a ? CST : b) -> (a ? CST1 : (convert)b) */ (simplify (convert (cond @0 CONSTANT_CLASS_P@1 @2)) (cond @0 (convert! @1) (convert @2))) ``` And the code produced by genmatch for generic is: ``` { tree _o1[1], _r1; _o1[0] =3D captures[2]; if (TREE_TYPE (_o1[0]) !=3D type) _r1 =3D fold_build1_loc (loc, NOP_EXPR, type, _o1[0]); if (EXPR_P (_r1)) goto next_after_fail867; else _r1 =3D _o1[0]; res_op2 =3D _r1; } ``` I think there is a missing `{`/`}` pair around the fold_build1_loc/if/goto statements.=