Deterministic worst-case execution for satisfying hard-real-time constraint
s, and speculative execution with rollback for improving average-case throu
ghput, appear to lie on opposite ends of a spectrum of performance requirem
ents and strategies. Nonetheless, we show that there are situations in whic
h speculative execution can improve the performance of a hard real-time sys
tem, either by enhancing average performance while not affecting the worst-
case, or by actually decreasing the worst-case execution time. The paper pr
oposes a set of compiler transformation rules to identify opportunities for
speculative execution and transform the code. Moreover, we have conducted
an extensive experiment using simulation of randomly generated real-time pr
ograms to evaluate applicability and profitability of speculative execution
. The simulation results indicate that speculative execution improves avera
ge execution time and program timeliness. Finally, a prototype implementati
on is described in which these transformations have been evaluated for real
istic applications.