[SDL] reRE: [OT] RE: [SDL] Windows version...

Mattias Engdegård f91-men at nada.kth.se
Wed Aug 8 05:41:01 PDT 2001

>Well, after finding some really scary code in SDL (which isn't ANSI legal,
>or illegal), a vectorC compiled version might be a way off (we've got to
>rewrite the compiler to get it working).

Please tell us about any errors or undefined constructs. SDL compiles
cleanly (modulo a few warnings) with the quite picky Sun WorkShop C
compiler, so I think it's mostly OK. I suspect there can be a bunch
of illegal aliases, however, and it would be useful to remove them
so we can use compilers with type-based alias detection.

>Sam, what the hell were you think when you wrote those DUFFS_LOOPS things?
>Everyone here in the office is damned confused about that

It's just a macro version of the old and well-known Duff's Device,
which does some "automatic" unrolling of loops in a compact way.

The problem is of course, as you no doubt have observed, that
it's quite inefficient. It made some sort of sense for ancient
architectures where unrolling was just to reduce the loop overhead
(increment counter, test, branch), as opposed to modern architectures
where unrolling is for increasing the basic block size and thus
enable better scheduling inside the loop body.

Since Duff's Device splits the loop body in several basic blocks,
there is little win at all (a loss in fact, since compilers that
vectorize, software-pipeline or unroll loops automatically are
prevented of doing this).

I have been thinking of fixing this in the SDL sources but I've
not really wanted to change working code, and I've sworn that
I will not allow that sort of thing to creep into SDL 1.3 :)

More information about the SDL mailing list