public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/54685] New: [SH] Improve unsigned int comparison with 0x7FFFFFFF
@ 2012-09-23 19:34 olegendo at gcc dot gnu.org
  2012-09-23 19:34 ` [Bug target/54685] " olegendo at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: olegendo at gcc dot gnu.org @ 2012-09-23 19:34 UTC (permalink / raw)
  To: gcc-bugs


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: olegendo@gcc.gnu.org
        ReportedBy: olegendo@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))
    ])


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

end of thread, other threads:[~2013-12-17 21:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-23 19:34 [Bug target/54685] New: [SH] Improve unsigned int comparison with 0x7FFFFFFF olegendo at gcc dot gnu.org
2012-09-23 19:34 ` [Bug target/54685] " olegendo at gcc dot gnu.org
2012-10-04 23:50 ` olegendo at gcc dot gnu.org
2012-10-08 10:09 ` olegendo at gcc dot gnu.org
2012-10-08 18:36 ` [Bug middle-end/54685] " olegendo at gcc dot gnu.org
2012-11-06 20:25 ` olegendo at gcc dot gnu.org
2013-02-04 23:03 ` olegendo at gcc dot gnu.org
2013-02-05  0:09 ` kkojima at gcc dot gnu.org
2013-02-15 21:28 ` olegendo at gcc dot gnu.org
2013-02-15 21:34 ` olegendo at gcc dot gnu.org
2013-12-17 21:07 ` olegendo 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).