public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/103439] New: genemit emits dead code
@ 2021-11-26 12:10 rguenth at gcc dot gnu.org
  2021-11-26 12:26 ` [Bug middle-end/103439] " ubizjak at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-26 12:10 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-29  7:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 12:10 [Bug middle-end/103439] New: genemit emits dead code rguenth at gcc dot gnu.org
2021-11-26 12:26 ` [Bug middle-end/103439] " ubizjak at gmail dot com
2021-11-26 12:28 ` rguenther at suse dot de
2021-11-26 13:11 ` ubizjak at gmail dot com
2021-11-26 13:38 ` rguenth at gcc dot gnu.org
2021-11-26 22:06 ` pinskia at gcc dot gnu.org
2021-11-29  7:21 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).