Re: [RFC] cleanup patches for strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Um, prev one was using push %reg. My fault.
push $imm gives the same result:

# gcc -O2 -falign-loops=64 t.c
# ./a.out
Took 9291 CPU cycles Took 8068 CPU cycles
Took 9080 CPU cycles Took 8058 CPU cycles
Took 9134 CPU cycles Took 8061 CPU cycles
Took 9084 CPU cycles Took 8043 CPU cycles
Took 9084 CPU cycles Took 8043 CPU cycles
Took 9084 CPU cycles Took 8043 CPU cycles

The source:

#define rdtscl(low) asm volatile("rdtsc" : "=a" (low) : : "edx")

#define NL "\n"

#include <stdio.h>

int main() {
    int i,k,start,end;
    int v = 1234;

for(k=0; k<6; k++) {
    rdtscl(start);
    for(i=0; i<1000; i++) {
        asm(NL
        "       push    %0" NL
        "       pop     %%eax" NL
        "       push    %0" NL
        "       pop     %%eax" NL
        "       push    %0" NL
        "       pop     %%eax" NL
        "       push    %0" NL
        "       pop     %%eax" NL
        : /* outputs */
        : "m" (v) /* inputs */
        : "ax" /* clobbers */
        );
    }
    rdtscl(end);
    printf("Took %u CPU cycles ", end-start);

    rdtscl(start);
    for(i=0; i<1000; i++) {
        asm(NL
        "       push    $1234" NL
        "       pop     %%eax" NL
        "       push    $1234" NL
        "       pop     %%eax" NL
        "       push    $1234" NL
        "       pop     %%eax" NL
        "       push    $1234" NL
        "       pop     %%eax" NL
        : /* outputs */
        : /* inputs */
        : "ax" /* clobbers */
        );
    }
    rdtscl(end);
    printf("Took %u CPU cycles\n", end-start);
}
    return 0;
}
--
vda

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux