public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/54272] New: [SH] Add support for addv / subv instructions
@ 2012-08-15 16:03 olegendo at gcc dot gnu.org
  2012-08-15 16:17 ` [Bug target/54272] " olegendo at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: olegendo at gcc dot gnu.org @ 2012-08-15 16:03 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54272
           Summary: [SH] Add support for addv / subv instructions
    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 addv and subv instructions can be used for at least two things:

1) Implementing trapping signed integer arithmetic (-ftrapv)

   Currently, for the SH target, trapping insns (e.g. addvsi3) are
   supposed to be implemented by library functions in libgcc.
   However, it seems that for addvsi3 and subvsi3 normal addsi3 and
   subsi3 patterns are expanded by the middle-end, which is wrong.
   Probably PR 35412 is related to this.
   After adding the addvsi3 pattern to sh.md, the middle-end picks it up
   as expected.
   However, I'm unsure how to realize the actual trapping part.
   The library functions in libgcc just invoke 'abort ()' on overflow.
   I think the trapa instruction could be used here to get relatively
   compact code, like:
           addv  r4,r5
           bf    0f
           trapa #???
         0:
   However, I have no idea which trapa immediate value would be
   suitable for this, especially for GNU/Linux environments.
   Maybe it's better to make this user configurable through an -m option?

2) Saturating arithmetic

   E.g. the pattern ssaddsi3 can be implemented with the following
   sequence (if I'm not mistaken):
          mov.l  .Lintmin, r1  ! r1 = 0x80000000
          cmp/pz r4      ! only one sign matters in case of overflow 
          negc   r1,r2   ! r5 = 0 - r1 - T
          addv   r4,r5
          bf     0f
          mov    r2,r5
      0:
   However, I don't know how to make the middle-end expand patterns that
   contain 'ss_plus'.  It seems that other targets provide the ssaddsi3
   pattern through target specific built-in functions only...


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

end of thread, other threads:[~2014-11-16  2:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-15 16:03 [Bug target/54272] New: [SH] Add support for addv / subv instructions olegendo at gcc dot gnu.org
2012-08-15 16:17 ` [Bug target/54272] " olegendo at gcc dot gnu.org
2012-08-16 11:24 ` kkojima at gcc dot gnu.org
2012-08-16 12:43 ` olegendo at gcc dot gnu.org
2012-08-16 13:00 ` kkojima at gcc dot gnu.org
2012-08-16 20:35 ` olegendo at gcc dot gnu.org
2013-09-19 11:07 ` olegendo at gcc dot gnu.org
2014-07-24 19:23 ` olegendo at gcc dot gnu.org
2014-11-16  2:26 ` 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).