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



             Bug #: 54685

           Summary: [SH] Improve unsigned int comparison with 0x7FFFFFFF

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: enhancement

          Priority: P3

         Component: target

        AssignedTo: olege...@gcc.gnu.org

        ReportedBy: olege...@gcc.gnu.org

            Target: sh*-*-*





The following cases:





int test_00 (unsigned int a)

{

  return !(a > 0x7FFFFFFF);

}





int test_01 (unsigned int a)

{

  return a <= 0x7FFFFFFF;

}



int test_02 (unsigned int a)

{

  return a < 0x80000000;

}



compile to (-m4 -O2):

        not     r4,r0

        shll    r0

        rts

        movt    r0



which would be better as:

        cmp/pz    r4    ! T = r4 >= 0 (signed)

        rts

        movt    r0





For some reason, these do not go through the cstoresi4 expander, but the

following does:



int test (unsigned int a)

{

  return a > 0;

}



The cstore is expanded by the middle-end into something like



(insn 6 3 7 2 (set (reg:SI 167)

        (not:SI (reg/v:SI 164 [ a ]))) sh_tmp.cpp:1984 185 {one_cmplsi2}

     (nil))

(insn 7 6 8 2 (parallel [

            (set (reg:SI 166 [ D.42391+-3 ])

                (lshiftrt:SI (reg:SI 167)

                    (const_int 31 [0x1f])))

            (clobber (reg:SI 147 t))

        ]) sh_tmp.cpp:1984 167 {lshrsi3_n_clobbers_t}

     (nil))





And combine then looks for:



Failed to match this instruction:

(parallel [

        (set (reg:SI 166 [ D.42391+-3 ])

            (ge:SI (reg:SI 4 r4 [ a ])

                (const_int 0 [0])))

        (clobber (reg:SI 147 t))

    ])

Reply via email to