public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-103439-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-11-26 12:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-26 12:10 rguenth at gcc dot gnu.org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103439-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).