Re: [PATCH] ipsum_calc_block: Optimize size and speed
Joakim Tjernlund/Transmode wrote on 2010/04/23 16:14:58:
Hello!
But you can't get rid of: z + (z < sum) which is the real bottleneck. Perhaps this doesn't cost much on high end CPUs but it sure does on embedded CPUs
Why should it be? It can be compiled as a sequence of "add with carry" instructions, can't it?
Yes, but have you seen gcc do that? I havn't, perhaps gcc has become smarter recently?
Jocke
Just tried this and it didn't with gcc 3.4.3 on PowerPC Some arch does not have an add with carry insn(MIPS?) Jocke unsigned long add32(unsigned long sum, unsigned long x) { unsigned long z = sum + x; return z + (z < sum); } /* gcc -O3 -S gives: .file "addc.c" .gnu_attribute 4, 2 .gnu_attribute 8, 1 .section ".text" .align 2 .globl add32 .type add32, @function
Hello!
Just tried this and it didn't with gcc 3.4.3 on PowerPC
It would be better to let gcc unroll the loop (if it is critical for performance, it should be unrolled anyway) and use a newer version of gcc.
Some arch does not have an add with carry insn(MIPS?)
Well, first of all, we should really get a clue about how much time is spent in the checksum function. Have a nice fortnight -- Martin `MJ' Mares <mj@ucw.cz> http://mj.ucw.cz/ Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth "I think it's a new feature. Don't tell anyone it was an accident. :-)" -- Larry Wall
Martin Mares <mj@ucw.cz> wrote on 2010/04/23 16:49:48:
Hello!
Just tried this and it didn't with gcc 3.4.3 on PowerPC
It would be better to let gcc unroll the loop (if it is critical for performance, it should be unrolled anyway) and use a newer version of gcc.
Oops, I meant gcc 4.3.4.
Some arch does not have an add with carry insn(MIPS?)
Well, first of all, we should really get a clue about how much time is spent in the checksum function.
Obviously it matters, otherwise why try to optimize it in the first place? While we wait for such results, perhaps we could just use a much simpler one? Jocke
participants (2)
-
Joakim Tjernlund -
Martin Mares