public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/52933] New: SH Target: Use div0s for integer sign comparisons
@ 2012-04-11 11:03 olegendo at gcc dot gnu.org
  2012-04-11 11:04 ` [Bug target/52933] " olegendo at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: olegendo at gcc dot gnu.org @ 2012-04-11 11:03 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52933
           Summary: SH Target: Use div0s for integer sign comparisons
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: olegendo@gcc.gnu.org
            Target: sh*-*-*


Created attachment 27130
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27130
Experimental patch to use div0s for sign comparisons

The div0s instruction can be used to implement some integer sign comparison
patterns such as:

int a = ...;
int b = ...;

(a ^ b) >= 0;
(a < 0) == (b < 0);
(a ^ b) >> 31;

etc.

For example, the following function

bool test (int a, int b)
{
  return (a ^ b) >= 0;
}

is compiled into:
        xor     r4,r5
        not     r5,r0
        mov     #-31,r1
        shld    r1,r0
        rts
        extu.b  r0,r0

but could be:
        div0s   r5,r4
        mov     #-1,r0
        rts
        negc    r0,r0


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

end of thread, other threads:[~2015-01-24 13:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-11 11:03 [Bug target/52933] New: SH Target: Use div0s for integer sign comparisons olegendo at gcc dot gnu.org
2012-04-11 11:04 ` [Bug target/52933] " olegendo at gcc dot gnu.org
2012-08-14 17:59 ` olegendo at gcc dot gnu.org
2012-08-15 16:05 ` olegendo at gcc dot gnu.org
2013-05-06 20:10 ` olegendo at gcc dot gnu.org
2014-12-17  1:52 ` olegendo at gcc dot gnu.org
2014-12-22 16:19 ` olegendo at gcc dot gnu.org
2015-01-24 13:05 ` 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).