diff mbox

PR 61662

Message ID 53BCF48F.60005@LimeGreenSocks.com
State New
Headers show

Commit Message

David Wohlferd July 9, 2014, 7:51 a.m. UTC
As requested, I am posting this patch to gcc-patches.

Problem description:
The detailed description and examples can be found in pr61662, but in 
short: using "#ifdef __x86_64__" to determine the size of a 'long' does 
not reliably yield the correct result.  This causes _lrotl and _lrotr to 
return incorrect results on LLP64 systems (like Windows).

ChangeLog:
2014-07-09  David Wohlferd <dw@LimeGreenSocks.com>

         PR target/61662
         * config/i386/ia32intrin.h: Use __LP64__ to determine size of long

dw

Comments

David Wohlferd July 12, 2014, 1:29 a.m. UTC | #1
Doh!  Since the component here is 'Target', I probably should have 
included the x86-64 Port Maintainer in the TO line.

Jan, while I have a release on file with the FSF, I don't have SVN write 
access.

dw

On 7/9/2014 12:51 AM, David Wohlferd wrote:
> As requested, I am posting this patch to gcc-patches.
>
> Problem description:
> The detailed description and examples can be found in pr61662, but in 
> short: using "#ifdef __x86_64__" to determine the size of a 'long' 
> does not reliably yield the correct result.  This causes _lrotl and 
> _lrotr to return incorrect results on LLP64 systems (like Windows).
>
> ChangeLog:
> 2014-07-09  David Wohlferd <dw@LimeGreenSocks.com>
>
>         PR target/61662
>         * config/i386/ia32intrin.h: Use __LP64__ to determine size of 
> long
>
> dw
diff mbox

Patch

Index: ia32intrin.h
===================================================================
--- ia32intrin.h	(revision 212190)
+++ ia32intrin.h	(working copy)
@@ -256,11 +256,7 @@ 
 
 #define _bswap64(a)		__bswapq(a)
 #define _popcnt64(a)		__popcntq(a)
-#define _lrotl(a,b)		__rolq((a), (b))
-#define _lrotr(a,b)		__rorq((a), (b))
 #else
-#define _lrotl(a,b)		__rold((a), (b))
-#define _lrotr(a,b)		__rord((a), (b))
 
 /* Read flags register */
 extern __inline unsigned int
@@ -280,6 +276,15 @@ 
 
 #endif
 
+/* on LP64 systems, longs are 64bits.  Use the appropriate rotate function */
+#ifdef __LP64__
+#define _lrotl(a,b)		__rolq((a), (b))
+#define _lrotr(a,b)		__rorq((a), (b))
+#else
+#define _lrotl(a,b)		__rold((a), (b))
+#define _lrotr(a,b)		__rord((a), (b))
+#endif
+
 #define _bit_scan_forward(a)	__bsfd(a)
 #define _bit_scan_reverse(a)	__bsrd(a)
 #define _bswap(a)		__bswapd(a)