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

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org

--- Comment #66 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Ivan Sorokin from comment #60)
> Another similar case. On this function:
> 
> unsigned wrap(unsigned index, unsigned limit)
> {
>     if (index >= limit)
>         index -= limit;
>     return index;
> }

This is actually PR97603.

We expand the above testcase to:

(insn 7 4 8 2 (set (reg:CC 17 flags)
        (compare:CC (reg/v:SI 99 [ index ])
            (reg/v:SI 100 [ limit ]))) "pr3507-1.c":3:8 15 {*cmpsi_1}
     (nil))
(jump_insn 8 7 9 2 (set (pc)
        (if_then_else (ltu (reg:CC 17 flags)
                (const_int 0 [0]))
            (label_ref 11)
            (pc))) "pr3507-1.c":3:8 1490 {*jcc}
     (int_list:REG_BR_PROB 536870913 (nil))
 -> 11)

(note 9 8 10 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(insn 10 9 11 4 (parallel [
            (set (reg/v:SI 99 [ index ])
                (minus:SI (reg/v:SI 99 [ index ])
                    (reg/v:SI 100 [ limit ])))
            (clobber (reg:CC 17 flags))
        ]) "pr3507-1.c":4:15 393 {*subsi_1}
     (nil))

which is the same as for testcase from PR97603:

(insn 7 4 8 2 (set (reg:CCGC 17 flags)
        (compare:CCGC (reg/v:SI 99 [ a ])
            (reg/v:SI 100 [ b ]))) "pr97603.c":5:8 15 {*cmpsi_1}
     (nil))
(jump_insn 8 7 9 2 (set (pc)
        (if_then_else (ge (reg:CCGC 17 flags)
                (const_int 0 [0]))
            (label_ref 13)
            (pc))) "pr97603.c":5:8 1490 {*jcc}
     (int_list:REG_BR_PROB 524845001 (nil))
 -> 13)

(note 9 8 10 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(insn 10 9 11 4 (parallel [
            (set (reg:SI 98 [ <retval> ])
                (minus:SI (reg/v:SI 99 [ a ])
                    (reg/v:SI 100 [ b ])))
            (clobber (reg:CC 17 flags))
        ]) "pr97603.c":6:18 393 {*subsi_1}
     (nil))

Please note that (insn 7) and (insn 10) could be merged to:

(define_insn "*sub<mode>_3"
  [(set (reg FLAGS_REG)
        (compare (match_operand:SWI 1 "nonimmediate_operand" "0,0,r,r,m")
                 (match_operand:SWI 2 "<general_operand>"
"<r><i>,<m>,r<i>,<m>,r<i>")))
   (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>,r,r,r")
        (minus:SWI (match_dup 1) (match_dup 2)))]
  "ix86_match_ccmode (insn, CCmode)
   && ix86_binary_operator_ok (MINUS, <MODE>mode, operands, TARGET_APX_NDD)"

Reply via email to