public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/58517] New: [SH] wrong code with subc and movsicc (-mpretend-cmove) after ce2
@ 2013-09-23 21:50 olegendo at gcc dot gnu.org
  2013-10-05 20:22 ` [Bug rtl-optimization/58517] icvt (after combine) puts ccreg clobbering insn between ccset insn and cc use olegendo at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: olegendo at gcc dot gnu.org @ 2013-09-23 21:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58517
           Summary: [SH] wrong code with subc and movsicc
                    (-mpretend-cmove) after ce2
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
            Target: sh*-*-*

While working on something else, I've noticed the following sequence in the
CSiBE set in the file zlib-1.1.4/infblock.s, compiling with -m4-single -ml -O2
-mpretend-cmove (trunk rev 201978):

.L257:
    sett        ! 1740    sett    [length = 2]
    mov    r2,r13    ! 2180    movsi_ie/2    [length = 2]
    sub    r5,r1    ! 1588    *subsi3_internal    [length = 2]
    subc    r5,r13    ! 1741    *subc    [length = 2]
    bt    0f    ! 1589    *movsicc_t_false/1    [length = 4]
    mov    r1,r13
0:
    tst    r13,r13    ! 435    cmpeqsi_t/1    [length = 2]
    bf    .L67    ! 436    *cbranch_t    [length = 2]
    bra    .L124
    nop        ! 2774    jump_compact    [length = 4]

The subc insn clobbers the T_REG and the following 'bt 0f' just looks wrong.
It seems that something goes wrong and the insn that does the test before
*movsicc_t_false gets eliminated because the sett-subc sequence is placed in
between.
After the combine pass the sequence looks like:

(note 422 421 423 45 [bb 45] NOTE_INSN_BASIC_BLOCK)
(insn 423 422 432 45 (set (reg:SI 147 t)
        (gtu:SI (reg/f:SI 424 [ D.2926 ])
            (reg/v/f:SI 189 [ q ]))) infblock.c:202 34 {cmpgtusi_t}
     (nil))
(insn 432 423 424 45 (set (reg/v:SI 190 [ n ])
        (minus:SI (reg/v/f:SI 423 [ q ])
            (reg/v/f:SI 189 [ q ]))) infblock.c:202 76 {*subsi3_internal}
     (expr_list:REG_DEAD (reg/v/f:SI 423 [ q ])
        (nil)))
(jump_insn 424 432 425 45 (set (pc)
        (if_then_else (eq (reg:SI 147 t)
                (const_int 0 [0]))
            (label_ref:SI 433)
            (pc))) infblock.c:202 295 {*cbranch_t}
     (expr_list:REG_DEAD (reg:SI 147 t)
        (expr_list:REG_BR_PROB (const_int 5000 [0x1388])
            (nil)))
 -> 433)
(note 425 424 426 46 [bb 46] NOTE_INSN_BASIC_BLOCK)
(note 426 425 427 46 NOTE_INSN_DELETED)
(insn 427 426 433 46 (parallel [
            (set (reg/v:SI 190 [ n ])
                (plus:SI (not:SI (reg/v/f:SI 189 [ q ]))
                    (reg/f:SI 424 [ D.2926 ])))
            (clobber (reg:SI 147 t))
        ]) infblock.c:202 74 {*subc}
     (expr_list:REG_UNUSED (reg:SI 147 t)
        (expr_list:REG_DEAD (reg/f:SI 424 [ D.2926 ])
            (nil))))
(code_label 433 427 434 47 70 "" [1 uses])


After the following pass ce2 it becomes:

(note 422 421 423 45 [bb 45] NOTE_INSN_BASIC_BLOCK)
(insn 423 422 432 45 (set (reg:SI 147 t)
        (gtu:SI (reg/f:SI 424 [ D.2926 ])
            (reg/v/f:SI 189 [ q ]))) infblock.c:202 34 {cmpgtusi_t}
     (nil))
(insn 432 423 1587 45 (set (reg/v:SI 190 [ n ])
        (minus:SI (reg/v/f:SI 423 [ q ])
            (reg/v/f:SI 189 [ q ]))) infblock.c:202 76 {*subsi3_internal}
     (expr_list:REG_DEAD (reg/v/f:SI 423 [ q ])
        (nil)))
(insn 1587 432 1588 45 (parallel [
            (set (reg:SI 945)
                (plus:SI (not:SI (reg/v/f:SI 189 [ q ]))
                    (reg/f:SI 424 [ D.2926 ])))
            (clobber (reg:SI 147 t))
        ]) infblock.c:202 74 {*subc}
     (nil))
(insn 1588 1587 1589 45 (set (reg:SI 946)
        (minus:SI (reg/v/f:SI 423 [ q ])
            (reg/v/f:SI 189 [ q ]))) infblock.c:202 76 {*subsi3_internal}
     (nil))
(insn 1589 1588 435 45 (set (reg/v:SI 190 [ n ])
        (if_then_else:SI (eq (reg:SI 147 t)
                (const_int 0 [0]))
            (reg:SI 946)
            (reg:SI 945))) infblock.c:202 54 {*movsicc_t_false}
     (nil))
(insn 435 1589 436 45 (set (reg:SI 147 t)
        (eq:SI (reg/v:SI 190 [ n ])
            (const_int 0 [0]))) infblock.c:202 17 {cmpeqsi_t}
     (nil))
(jump_insn 436 435 1378 45 (set (pc)
        (if_then_else (eq (reg:SI 147 t)
                (const_int 0 [0]))
            (label_ref 501)
            (pc))) infblock.c:202 295 {*cbranch_t}
     (expr_list:REG_DEAD (reg:SI 147 t)
        (expr_list:REG_BR_PROB (const_int 10000 [0x2710])
            (nil)))
 -> 501)

which is wrong.  I haven't checked whether it also happens on current trunk.


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-06-04  0:48 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-23 21:50 [Bug target/58517] New: [SH] wrong code with subc and movsicc (-mpretend-cmove) after ce2 olegendo at gcc dot gnu.org
2013-10-05 20:22 ` [Bug rtl-optimization/58517] icvt (after combine) puts ccreg clobbering insn between ccset insn and cc use olegendo at gcc dot gnu.org
2013-10-05 21:16 ` [Bug rtl-optimization/58517] icvt (after combine) puts ccreg clobbering insn between ccset insn and ccreg use olegendo at gcc dot gnu.org
2013-10-05 22:17 ` olegendo at gcc dot gnu.org
2013-10-05 23:23 ` steven at gcc dot gnu.org
2015-09-11 11:12 ` [Bug rtl-optimization/58517] ifcvt " ktkachov at gcc dot gnu.org
2023-06-02  1:38 ` pinskia at gcc dot gnu.org
2023-06-02  1:43 ` pinskia at gcc dot gnu.org
2023-06-02  1:44 ` pinskia at gcc dot gnu.org
2023-06-02  7:28 ` pinskia at gcc dot gnu.org
2023-06-02  7:57 ` pinskia at gcc dot gnu.org
2023-06-03  8:58 ` olegendo at gcc dot gnu.org
2023-06-03  9:02 ` pinskia at gcc dot gnu.org
2023-06-03 21:50 ` pinskia at gcc dot gnu.org
2023-06-03 22:18 ` pinskia at gcc dot gnu.org
2023-06-03 22:23 ` olegendo at gcc dot gnu.org
2023-06-03 22:59 ` pinskia at gcc dot gnu.org
2023-06-04  0:48 ` pinskia at gcc dot gnu.org

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).