Why loop_unrolling_find_unrollable_loop()? Usually we just iterate over all instructions, why are we not doing that here?
Because we need to clone the blocks every time we attempt an unroll: as soon as an unroll is successful we have to clone the result as future unrolls might fail, so looping through the entire block once isn't feasible without poking with `clone_block`'s `struct clone_instr_map` to remap `loop->next` from the original block to the cloned one.
I don't understand.
With all that said, I still don't think we should need to mess with copy prop. What we should be able to do is something more like this: [code snippet]
This is close to what this PR does, but it would run into the variable invalidation issue I mentioned above, and would also have a noticeable performance impact as copy prop would have to visit n² `if !broken`s.
By "variable invalidation issue" I gather you mean "poor performance with continue, because the compiler can't tell that the iteration block is executed on all branches"? Let's set that aside for now.
How bad is the performance penalty from visiting n² "if" blocks? Have you benchmarked it? I suspect that we should try to find a way to optimize copyprop independently of unrolling, if it's a problem.