public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rsandifo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107404] [12/13 Regression] Wrong code with -O3 since r12-6416-g037cc0b4a6646cc8
Date: Wed, 26 Oct 2022 11:13:55 +0000	[thread overview]
Message-ID: <bug-107404-4-WfNYkZtnMM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107404-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107404

rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sayle at gcc dot gnu.org,
                   |                            |uros at gcc dot gnu.org
             Status|ASSIGNED                    |NEW
           Assignee|rsandifo at gcc dot gnu.org        |unassigned at gcc dot gnu.org

--- Comment #3 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
This is due to the peephole2 added in r12-2640-gf7bf03cf69cc:

;; Eliminate a reg-reg mov by inverting the condition of a cmov (#2).
;; mov r2,r3; mov r0,r1; dec r0; cmov r0,r2 -> dec r1; mov r0,r3; cmov r0, r1
(define_peephole2
 [(set (match_operand:SWI248 2 "general_reg_operand")
       (match_operand:SWI248 3 "general_gr_operand"))
  (set (match_operand:SWI248 0 "general_reg_operand")
       (match_operand:SWI248 1 "general_reg_operand"))
  (parallel [(set (reg FLAGS_REG) (match_operand 5))
             (set (match_dup 0) (match_operand:SWI248 6))])
  (set (match_dup 0)
       (if_then_else:SWI248 (match_operator 4 "ix86_comparison_operator"
                             [(reg FLAGS_REG) (const_int 0)])
        (match_dup 0)
        (match_dup 2)))]
 "TARGET_CMOVE
  && REGNO (operands[2]) != REGNO (operands[0])
  && REGNO (operands[2]) != REGNO (operands[1])
  && peep2_reg_dead_p (2, operands[1])
  && peep2_reg_dead_p (4, operands[2])
  && !reg_overlap_mentioned_p (operands[0], operands[3])"
 [(parallel [(set (match_dup 7) (match_dup 8))
             (set (match_dup 1) (match_dup 9))])
  (set (match_dup 0) (match_dup 3))
  (set (match_dup 0) (if_then_else:SWI248 (match_dup 4)
                                          (match_dup 1)
                                          (match_dup 0)))]
{
  operands[7] = SET_DEST (XVECEXP (PATTERN (peep2_next_insn (2)), 0, 0));
  operands[8] = replace_rtx (operands[5], operands[0], operands[1], true);
  operands[9] = replace_rtx (operands[6], operands[0], operands[1], true);
})

The conditions make sure that the 2<-3 and 0<-1 moves are independent,
but they don't check what effect the 2<-3 move has on the third
instruction.  I don't know if the intention was to exclude cases
where operands 5 and 6 reference operand 2, or whether the intention
was to cope with those cases where possible.

  parent reply	other threads:[~2022-10-26 11:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26  0:40 [Bug tree-optimization/107404] New: [12/13 Regression] Wrong code with -O3 vsevolod.livinskiy at gmail dot com
2022-10-26  0:59 ` [Bug tree-optimization/107404] " pinskia at gcc dot gnu.org
2022-10-26  1:07 ` pinskia at gcc dot gnu.org
2022-10-26  6:36 ` [Bug tree-optimization/107404] [12/13 Regression] Wrong code with -O3 since r12-6416-g037cc0b4a6646cc8 marxin at gcc dot gnu.org
2022-10-26  6:36 ` marxin at gcc dot gnu.org
2022-10-26  8:58 ` rsandifo at gcc dot gnu.org
2022-10-26  9:05 ` jakub at gcc dot gnu.org
2022-10-26 11:13 ` rsandifo at gcc dot gnu.org [this message]
2022-11-03  9:29 ` [Bug target/107404] " ubizjak at gmail dot com
2022-11-03 10:00 ` ubizjak at gmail dot com
2022-11-03 13:18 ` cvs-commit at gcc dot gnu.org
2022-11-03 16:13 ` cvs-commit at gcc dot gnu.org
2022-11-03 16:18 ` ubizjak at gmail dot com

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-107404-4-WfNYkZtnMM@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).