public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Richard Biener <richard.guenther@gmail.com>,
	 "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] combine: Fix ICE in try_combine on pr112494.c [PR112560]
Date: Thu, 30 Nov 2023 10:09:05 +0100	[thread overview]
Message-ID: <CAFULd4ZxUxFJ5_RW55xHJYdx4X3QqxSKPByJRj7ZeS1fzayFpg@mail.gmail.com> (raw)
In-Reply-To: <20231130081858.GH19790@gate.crashing.org>

On Thu, Nov 30, 2023 at 9:21 AM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> Hi!
>
> On Wed, Nov 29, 2023 at 02:20:03PM +0100, Uros Bizjak wrote:
> > On Wed, Nov 29, 2023 at 1:25 PM Richard Biener
> > <richard.guenther@gmail.com> wrote:
> > > On Wed, Nov 29, 2023 at 10:35 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> > I was assuming that if the CC reg is not used inside the comparison,
> > then the mode of CC reg is irrelevant. We can still combine the
> > instructions into new insn, without updating the use of CC reg.
>
> It should never happen that the CC reg is not used, so what does this
> mean?

I was trying to say that when CC reg is used inside the comparison, e.g.:

(define_insn "*setcc_qi"
  [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
    (match_operator:QI 1 "ix86_comparison_operator"
      [(reg FLAGS_REG) (const_int 0)]))]
  ""
  "set%C1\t%0"

and through the%C operand modifier we call put_condition_code, the
mode of CC reg is checked and a different instruction is emitted,
depending on the CC reg mode. Please also note that not all comparison
operators are handled, so when the combine rewrites the comparison, it
isn't necessarily supported.

This is in contrast with:

(define_insn "@pushfl<mode>2"
  [(set (match_operand:W 0 "push_operand" "=<")
    (unspec:W [(match_operand:CC 1 "flags_reg_operand")]
          UNSPEC_PUSHFL))]

where we don't care about CC reg mode at all. The CC reg is not in the
comparison, so the mode does not matter. The combination of
instructions should not be limited by CC reg user in this case.

>
> Where it is used might not be a comparison of course, as in your
> example.
>
> >         && (cc_use_loc = find_single_use (SET_DEST (newpat), i3,
> >                                           &cc_use_insn)))
> >       {
> > -       compare_code = orig_compare_code = GET_CODE (*cc_use_loc);
> > -       if (is_a <scalar_int_mode> (GET_MODE (i2dest), &mode))
> > -         compare_code = simplify_compare_const (compare_code, mode,
> > -                                                &op0, &op1);
> > -       target_canonicalize_comparison (&compare_code, &op0, &op1, 1);
> > +       if (COMPARISON_P (*cc_use_loc))
> > +         {
> > +           compare_code = orig_compare_code = GET_CODE (*cc_use_loc);
> > +           if (is_a <scalar_int_mode> (GET_MODE (i2dest), &mode))
> > +             compare_code = simplify_compare_const (compare_code, mode,
> > +                                                    &op0, &op1);
> > +           target_canonicalize_comparison (&compare_code, &op0, &op1, 1);
> > +         }
> > +       else
> > +         {
> > +           if (dump_file && (dump_flags & TDF_DETAILS))
> > +             fprintf (dump_file, "CC register not used in comparison.\n");
>
> "Where the CCmode register is used is not a comparison".  But more
> compact if you can manage (I cannot).

Perhaps "CCmode register user is not a comparison." ?

Uros.

  reply	other threads:[~2023-11-30  9:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29  9:34 Uros Bizjak
2023-11-29 12:25 ` Richard Biener
2023-11-29 13:20   ` Uros Bizjak
2023-11-30  8:18     ` Segher Boessenkool
2023-11-30  9:09       ` Uros Bizjak [this message]
2023-12-04  9:34   ` Uros Bizjak
2023-12-07 12:09     ` Richard Biener

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=CAFULd4ZxUxFJ5_RW55xHJYdx4X3QqxSKPByJRj7ZeS1fzayFpg@mail.gmail.com \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=segher@kernel.crashing.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).