3 ms·
I'm not sure if the compiler is smart enough to do it for you, but you might be able to squeak a bit more performance by precomputing a partial sum (data + V_LE
by eyegor 7y ago
I'm not sure if the compiler is smart enough to do it for you, but you might be able to squeak a bit more performance by precomputing a partial sum (data + V_LEN - 1) outside the loop for this statement:
> v_load(data + offset + V_LEN - 1);
Other than that, this is incredibly clean code and I doubt you can get much more performance without dropping into assembly. I wish my coworkers made code this well documented :/
- zwegner 7y agoAt least my compiler (LLVM 10) is smart enough to know that "data" isn't modified, and thus fold the addresses of the two vector loads inside the main loop into single instructions: 1a0: c5 fe 6f 6c 31 ff vmovdqu ymm5,YMMWORD PTR [rcx+rsi*1-0x1] 1a6: c5 fe 6f 24 31 vmovdqu ymm4,YMMWORD PTR [rcx+rsi*1] I'd expect most modern compilers to get this right with optimizations on, but if somebody finds one that doesn't, I'd like to know. In general, I read through the disassembly a decent amount when developing this. That's how I noticed the "req += (vmask2_t)set << n;" (instead of |=) trick, which gets compiled to one lea instruction. The disassembly got a little bit hairy when I added the code to handle trailing bytes, though... Thanks for the kind words, though! It warms my heart :)
- vardump 7y ago> I'm not sure if the compiler is smart enough to do it for you, but you might be able to squeak a bit more performance by precomputing a partial sum (data + V_LEN - 1) outside the loop for this statement: I don't remember last time when a compiler did not do this for me. Compilers are generally pretty smart nowadays.