public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kkojima at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65153] [SH][4.9 Regression] "insn does not satisfy its constraints" when compiling libmcrypt
Date: Sun, 22 Feb 2015 05:18:00 -0000	[thread overview]
Message-ID: <bug-65153-4-FnKdEJYomt@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-65153-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Kazumoto Kojima <kkojima at gcc dot gnu.org> ---
Created attachment 34828
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34828&action=edit
reduced testcase

Looks an interesting "why didn't we see it?" target bug.
The problem happens at peephole2 phase.  The insn sequence

(insn 353 103 105 4 (set (reg:SI 1 r1) (reg:SI 6 r6)))
(insn 105 353 106 4 (set (reg:SI 7 r7) (ashift:SI (reg:SI 7 r7) (reg:SI 0
r0))))
(insn 106 105 107 4 (set (reg/v:SI 6 r6)
             (ior:SI (reg:SI 6 r6) (reg:SI 7 r7))))

is tested by the complex peephole

(define_peephole2
  [(set (match_operand 0 "any_register_operand" "")
    (match_operand 1 "any_register_operand" ""))
   (set (match_operand 2 "any_register_operand" "") (match_operand 3 "" ""))
   (set (match_operand 4 "" "") (match_operand 5 "" ""))]
  "(HARD_REGNO_NREGS (REGNO (operands[0]), GET_MODE (operands[2]))
    <= HARD_REGNO_NREGS (REGNO (operands[0]), GET_MODE (operands[0])))
   && peep2_reg_dead_p (3, operands[0]) && peep2_reg_dead_p (3, operands[2])
   && ! FIND_REG_INC_NOTE (peep2_next_insn (2), operands[0])
   && ! FIND_REG_INC_NOTE (peep2_next_insn (2), operands[2])
   && ! reg_overlap_mentioned_p (operands[0], operands[3])
   && ! reg_overlap_mentioned_p (operands[2], operands[0])
   && ! reg_overlap_mentioned_p (operands[0], operands[1])
   && (REGNO_REG_CLASS (REGNO (operands[0]))
       == REGNO_REG_CLASS (REGNO (operands[2])))
   && (REGNO_REG_CLASS (REGNO (operands[1]))
       == REGNO_REG_CLASS (REGNO (operands[0])))"
  [(set (match_dup 0) (match_dup 3))
   (set (match_dup 4) (match_dup 5))]
{
  ...

This peephole2 in sh.md tries to replace operands[0] with operands[1]
and operands[2] with operands[0] in operands[4]/operands[5].  In our
case, operands[5] is (ior:SI (reg:SI 6 r6) (reg:SI 7 r7)) and the peephole
tries to do term rewriting r1 -> r6, r7 -> r1.  This peephole fails
after all and then tries to restore operands[5] with term rewriting
r6 -> r1, r1 -> r7.  Unfortunately this can't reverse the first term
rewriting and yields (ior:SI (reg:SI 1 r1) (reg:SI 7 r7)).  Thus we
got a wrong insn
(set (reg/v:SI 6 r6) (ior:SI (reg:SI 1 r1) (reg:SI 7 r7))).


  parent reply	other threads:[~2015-02-22  4:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-21  9:52 [Bug target/65153] New: sh: " glaubitz at physik dot fu-berlin.de
2015-02-21 13:46 ` [Bug target/65153] " olegendo at gcc dot gnu.org
2015-02-21 14:41 ` glaubitz at physik dot fu-berlin.de
2015-02-21 15:07 ` [Bug target/65153] [SH][4.9 Regression] " olegendo at gcc dot gnu.org
2015-02-21 15:30 ` olegendo at gcc dot gnu.org
2015-02-21 17:07 ` olegendo at gcc dot gnu.org
2015-02-22  5:18 ` kkojima at gcc dot gnu.org [this message]
2015-02-22  5:20 ` kkojima at gcc dot gnu.org
2015-02-22 14:48 ` olegendo at gcc dot gnu.org
2015-02-22 23:49 ` olegendo at gcc dot gnu.org
2015-02-23  0:13 ` kkojima at gcc dot gnu.org
2015-02-23  1:19 ` olegendo at gcc dot gnu.org
2015-02-23  8:19 ` kkojima at gcc dot gnu.org
2015-02-23 10:58 ` rguenth at gcc dot gnu.org
2015-02-25  5:45 ` kkojima at gcc dot gnu.org
2015-02-25  6:30 ` kkojima at gcc dot gnu.org
2015-03-07 19:35 ` olegendo 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-65153-4-FnKdEJYomt@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).