The theoretical speedup of a pipeline is calculated as the number of stages in the pipeline. For a 4-stage pipeline, the theoretical speedup would be 4. In this case, with a clock cycle of 20ns and processing 100 tasks, the total time taken to process all tasks would be 20ns * 100 = 2000ns. With a 4-stage pipeline, the time taken to process all tasks would be 2000ns / 4 = 500ns, resulting in a theoretical speedup of 4.