Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What's not worth it? Loop unrolling? Something else?


Does duff's device create irreducible control flow? I couldn't tell you off the top of my head but seems likely and if it does that's a good reason to avoid as some modern compilers do not like irreducible control flow.


Yes, it creates a loop with multiple entry points, which is irreducible. (I think it's even one of several equivalent definitions of irreducibility.)


Putting the code into Godbolt the control flow

      switch (count % 8) {
turns into

          jmp     [QWORD PTR .L4[0+rdx*8]]
just like you'd do if you were doing the assembly by hand.


Yes that’s how gcc implements a switch. But what’s they got to do with irreducibility?


'irriducible'?


It comes from 'reduce' - I think it's spelt 'irreducible', but maybe you're American and I'm British.


Made me smile. No, I'm questioning the meaning here. I have a vague inkling it's a property of the dataflow graph of a program, I'm just struggling to remember what. Is it literally that repeated collapses of basic node types (if/while/sequence) will end up with a single node? Basically 'does it properly nest'? Or is it something else? (and I'm a brit too BTW)


Yes it means properly-nested, or really the same thing as 'structured' as in 'structured programming.' I'm sure there's some graph-theoretic definition but I don't know it off the top of my head.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: