public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/7006] New: Bad left shift in _FP_FRAC_SRS_2 macro in soft-fp/op-2.h on SH-4
@ 2008-11-05 16:12 ilyes dot gouta at gmail dot com
  0 siblings, 0 replies; only message in thread
From: ilyes dot gouta at gmail dot com @ 2008-11-05 16:12 UTC (permalink / raw)
  To: glibc-bugs

Hi all,

I hit this bug two years ago while porting a VM on SH-4. The bug is located in
soft-fp/op-2.h, in the macro _FP_FRAC_SRS_2. The bug is in the line 95:

X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) | \

I had to change it to:

X##_f0 = ((X##_f1 << (_FP_W_TYPE_SIZE - (N) - 1)) << 1 | X##_f0 >> (N) | \

Because in the extreme case where you have N == 0 and _FP_W_TYPE_SIZE == 32,
X##_f1 << (_FP_W_TYPE_SIZE - (N)) would return 0, however on SH-4, it returns
X##_f1 since only 5 bits are used in the shift instruction, SHLD, to encode the
shift amount, and 32 (which spans 6 bits) will be masked to 0. This issue can
also be attributed to the SH-4 GCC compiler.

Regards,
Ilyes Gouta.

-- 
           Summary: Bad left shift in _FP_FRAC_SRS_2 macro in soft-fp/op-2.h
                    on SH-4
           Product: glibc
           Version: 2.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: ilyes dot gouta at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=7006

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-05 16:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-05 16:12 [Bug math/7006] New: Bad left shift in _FP_FRAC_SRS_2 macro in soft-fp/op-2.h on SH-4 ilyes dot gouta at gmail dot com

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).