https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103439
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 = 0;
start_sequence ();
{
rtx operands[2];
operands[0] = operand0;
operands[1] = operand1;
#define FAIL _Pragma ("GCC error \"nearbyinthf2 cannot FAIL\"") (void)0
#define DONE return (_val = 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 = operands[0];
(void) operand0;
operand1 = operands[1];
(void) operand1;
}
emit (operand0, true);
emit (operand1, false);
_val = 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.