We know that each task will either contain all of the common instructions (this is true for one task) or none of the common instructions (which will be true for the remaining tasks).
The common instructions must reside in the same task, because they can per definition not be entirely independent (remember, they all contribute to the change of the same variable). Some of the common instructions can be independent and thus placed in separate tasks, but if this was exploited by the sequence parallelizer, we would have known earlier, since we would not have received a number of independent tasks then.
To identify the task that contains the common instructions, we should simply search for any instruction that touches the loop variable, that is, an instruction that contains the loop variable in it's touches set. Any instruction that touches the loop variable is per definition a common instruction, and the remaining common instructions are bound to reside in the same task.
Note that we make a lot of assumptions on correctness of the sequence parallelizer and other things here. This code is not fault tolerant, and is therefore also fitted with a large number of sanity checks throughout the code. Of course code should not be faulty, but this code must be absolutely correct not to break completely, something that makes debugging interesting.
When we have identified the task that contains the common instructions, we append the common instructions to all remaining tasks.
The common instructions must be appended, not prepended, because we know that even though the code may use the data touched by the common instructions, it will never depend on the results from the common instructions before the next iteration in the loop.
If this was not true, the sequence parallelizer could not have parallelized the code the way it did. It distributed the common instructions out into one task, and all the remaining tasks will be using the values of the variables touched by the common instructions as they where before the common instructions touches them, for the current iteration.