public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "steven at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/43597] Move and compare with 0 can be combined
Date: Wed, 31 Mar 2010 14:59:00 -0000	[thread overview]
Message-ID: <20100331145910.21175.qmail@sourceware.org> (raw)
In-Reply-To: <bug-43597-17659@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from steven at gcc dot gnu dot org  2010-03-31 14:59 -------
In .final, the insns look like this:
@(insn:TI 9 7 8 t.c:8 (set (reg:CC 24 cc)
@        (compare:CC (reg:SI 0 r0 [orig:134 f ] [134])
@            (const_int 0 [0x0]))) 220 {*arm_cmpsi_insn} (expr_list:REG_DEAD
(reg:SI 0 r0 [orig:134 f ] [134])
@        (nil)))
        cmp     r0, #0  @ 9     *arm_cmpsi_insn/1       [length = 4]
@(insn 8 9 10 t.c:7 (set (reg/v:SI 5 r5 [orig:134 f ] [134])
@        (reg:SI 0 r0)) 658 {*thumb2_movsi_insn} (nil))
        mov     r5, r0  @ 8     *thumb2_movsi_insn/1    [length = 4]



This, AFAICT, would match with the pattern and constraints of movsi_compare0:

;; If copying one reg to another we can set the condition codes according to
;; its value.  Such a move is common after a return from subroutine and the
;; result is being tested against zero.

(define_insn "*movsi_compare0"
  [(set (reg:CC CC_REGNUM)
        (compare:CC (match_operand:SI 1 "s_register_operand" "0,r")
                    (const_int 0)))
   (set (match_operand:SI 0 "s_register_operand" "=r,r")
        (match_dup 1))]
  "TARGET_32BIT"
  "@
   cmp%?\\t%0, #0
   sub%.\\t%0, %1, #0"
  [(set_attr "conds" "set")]
)


But this insns can probably only be formed in the .combine pass, since (to the
best of my knowledge) we don't construct multiple-set insns in any other pass.

In the .combine pass, the two insns look like this (obviously reversed, as you
could already suspect from the insns numbers 9 and 8 above):

(insn 8 7 9 2 t.c:7 (set (reg/v:SI 134 [ f ])
        (reg:SI 0 r0)) 658 {*thumb2_movsi_insn} (expr_list:REG_DEAD (reg:SI 0
r0)
        (nil)))

(insn 9 8 10 2 t.c:8 (set (reg:CC 24 cc)
        (compare:CC (reg/v:SI 134 [ f ])
            (const_int 0 [0x0]))) 220 {*arm_cmpsi_insn} (nil))

But combine does not even try to combine these two insns:
------------
...
insn_cost 24: 0

Trying 9 -> 10:
Failed to match this instruction:
(set (pc)
    (if_then_else (lt (reg/v:SI 134 [ f ])
            (const_int 0 [0x0]))
        (label_ref:SI 29)
        (pc)))


foo4
...
------------


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43597


  parent reply	other threads:[~2010-03-31 14:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-31  7:50 [Bug target/43597] New: " carrot at google dot com
2010-03-31  7:51 ` [Bug target/43597] " carrot at google dot com
2010-03-31  9:01 ` steven at gcc dot gnu dot org
2010-03-31  9:08 ` ramana at gcc dot gnu dot org
2010-03-31 14:59 ` steven at gcc dot gnu dot org [this message]
2010-03-31 15:16 ` steven at gcc dot gnu dot org
2010-03-31 22:50 ` steven at gcc dot gnu dot org
2010-03-31 22:51 ` steven at gcc dot gnu dot org
2010-04-17 17:15 ` rearnsha at gcc dot gnu dot org
2010-04-22 12:26 ` carrot at google dot com
     [not found] <bug-43597-4@http.gcc.gnu.org/bugzilla/>
2011-08-17 11:45 ` vries at gcc dot gnu.org
2011-08-17 13:05 ` vries 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=20100331145910.21175.qmail@sourceware.org \
    --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).