3 ms·
What's not worth it? Loop unrolling? Something else?
by marvy 6y ago
What's not worth it? Loop unrolling? Something else?
- chrisseaton 6y agoDoes 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.
- tom_mellior 6y agoYes, it creates a loop with multiple entry points, which is irreducible. (I think it's even one of several equivalent definitions of irreducibility.)
- throwaway_pdp09 6y ago'irriducible'?
- chrisseaton 6y agoIt comes from 'reduce' - I think it's spelt 'irreducible', but maybe you're American and I'm British.
- throwaway_pdp09 6y agoMade 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)
- chrisseaton 6y agoYes 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.
- Symmetry 6y agoPutting 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.
- chrisseaton 6y agoYes that’s how gcc implements a switch. But what’s they got to do with irreducibility?