tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Revert "Optimize vswap()"


From: grischka
Subject: Re: [Tinycc-devel] Revert "Optimize vswap()"
Date: Tue, 15 Jan 2013 15:54:55 +0100
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Kirill Smelkov wrote:
grischka! Could you please Cc relevant people when talking about
reverting their patches? I was unaware of this issue until recently.
Some of us read lists in batches through gmane...

Okay ...

I'd suggest to move that optimization into its own function
        void memswap(void *p1, void *p2, size_t n);

For it to work effectively that memswap should be static inline and

Yep, static inline.

contains test for n to be builtin constant and be more "ugly" in your
speak, and also that __builtin_constant() tests might not work out of
the box in tcc...

Forget everything __builtin_GCC, to begin with.

or otherwise to revert it.

Maybe let's just do it step by step and fix _STATIC_ASSERT for win32?
Especially there is already one in

    win32/include/malloc.h:#define _STATIC_ASSERT(expr) extern void 
__static_assert_t(int [(expr)?1:-1])

#ifndef _MSVC
# define _STATIC_ASSERT     // from ccan
#else
# define _STATIC_ASSERT     // for msvc
#endif

?


Optimizing vswap() was an easy win and given tinycc goal is to be fast
compiler I suggest not to revert it.

On the other hand I have no microsoft compilers installation nor any
windows on my machines, and thus can't test how the code works/breaks there.
That _STATIC_ASSERT was taken from CCAN[1] which is valuable and quality
library for C.

Forget _STATIC_ASSERT, also.  It is not C.  It is a trick.  C is a
language to let the compiler know what you want:

        while (n % sizeof tmp)
           ...

And then let the compiler optimize out redundancy.  Therefore
"static inline" I suppose.

No offences, but ruling out speedups on msvc non-standartness is not
wise imho.

Hm.  For me the point is not msvc but readability.  Understand
vswap and you understand tinycc.  I'd rather not stress people's
eyes with such backslash monster in that place as long as we want
them to fix our bugs.

I'm open to fixing it, just please cc me, and please provide advices
with msvc.

It's a C compiler. ;)  I don't know how Fabrice did it but IIRC
the entire tinycc compiled basically out of the box as soon as
msvc had long long.

Anyway, you can do it.  Take the idea, add reusability and
portability.   And so "Kirill's memswap" shall still be famous
when tinycc was forgotten long time ago ....

Thanks,

--- grischka




reply via email to

[Prev in Thread] Current Thread [Next in Thread]