From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 699A3385780F; Fri, 26 Nov 2021 12:10:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 699A3385780F From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/103439] New: genemit emits dead code Date: Fri, 26 Nov 2021 12:10:49 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Nov 2021 12:10:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103439 Bug ID: 103439 Summary: genemit emits dead code Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- Patterns like (define_expand "nearbyinthf2" [(match_operand:HF 0 "register_operand") (match_operand:HF 1 "nonimmediate_operand")] "TARGET_AVX512FP16" { emit_insn (gen_sse4_1_roundhf2 (operands[0], operands[1], GEN_INT (ROUND_MXCSR | ROUND_NO_EXC))); DONE; }) generate /* /home/rguenther/src/trunk/gcc/config/i386/i386.md:18636 */ rtx gen_nearbyinthf2 (rtx operand0, rtx operand1) { rtx_insn *_val =3D 0; start_sequence (); { rtx operands[2]; operands[0] =3D operand0; operands[1] =3D operand1; #define FAIL _Pragma ("GCC error \"nearbyinthf2 cannot FAIL\"") (void)0 #define DONE return (_val =3D get_insns (), end_sequence (), _val) #line 18640 "/home/rguenther/src/trunk/gcc/config/i386/i386.md" { emit_insn (gen_sse4_1_roundhf2 (operands[0], operands[1], GEN_INT (ROUND_MXCSR | ROUND_NO_EXC))); DONE; } #undef DONE #undef FAIL operand0 =3D operands[0]; (void) operand0; operand1 =3D operands[1]; (void) operand1; } emit (operand0, true); emit (operand1, false); _val =3D get_insns (); end_sequence (); return _val; } where the code after DONE is not reachable. With a proposed -Wunreachable-code-return this diagnoses most expander patterns. I'm not sure if there are valid cases where we have a mix of a direct RTL pattern and manual expansion, so where the { } part falls thru.=