This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][s390] Replace lll_futex_* assembly code with INTERNAL_SYSCALL


On 12/20/2012 09:01 PM, Siddhesh Poyarekar wrote:
On Thu, Dec 20, 2012 at 02:19:53PM -0500, Carlos O'Donell wrote:
-    __result > -4096UL;							      \
+    __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp),		      \
+			      __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+			      (nr_wake), (nr_move), (mutex), (val));	      \
+    INTERNAL_SYSCALL_ERROR_P (__ret, __err);				      \

OK.


What generates better code?

__result > -4096UL; or ((unsigned long) (val) >= -4095UL)?

Is the compiler smart enough to generate the same code?


For S-390, it is the same C code:


#define INTERNAL_SYSCALL_ERROR_P(val, err)                                    \
   ((unsigned int) (val) >= 0xfffff001u)

so the compiler should generate the same code.

Should... :-)


I verified that either > or >= generates the same assembly.

In both cases the compiler converts >= into >, and -4095 into -4096.

I note that the constant used in the comparison is placed into
.rodata, and that loading it from .rodata seems expensive
(not to mention requires a relocation), but I guess materializing
a 32-bit constant must be even more expense? It would seem to me
that we could materialize -4096 with a simple immediate load and
shift? Question for another day.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]