[lkml]   [2001]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] take 2 of the tr-based current
Anton Blanchard wrote:

>I changed the code a bit so that get_cpu() is now inline - this
>represents our situation better. I think it is valid for gcc to cache
>get_cpu across a function call in the below example because it knows
>that get_cpu does not refer to any global variables.
You are right: it seems that gcc internally decides if an inline
function is const or pure.

static inline int get_TR(void)
int reg;
__asm__ (
"rep; nop;\n\t"
"xor %0,%0\n\t"
: "=r" (reg));
return ret;

is always optimized as if get_TR is a function with __attribute__((const)).

Ben, is it intentional that get_TR is _not_ marked as inline? Your
version produces explicit function calls with -O2, and incorrect code
with -O99 (gcc decides to inline get_TR even without an inline
directive, and then optimizes away the calls after schedule.)

It seems that Anton's version generates the best code.
I've tested the attached version with egcs-1.1.2, gcc-2.96-98 and
gcc3-3.0.1-3, with -O0, -O2 and -O99.


[unhandled content-type:application/msword]
 \ /
  Last update: 2005-03-22 13:13    [W:0.089 / U:2.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site