Tighter Timing Predictions by Automatic Detection and Exploitation of Value-Dependent Constraints Christopher Healy and David Whalley Computer Science Department, Florida State University, Tallahassee, FL 32306-4530 e-mail: {healy,whalley}@cs.fsu.edu, phone: (850) 644-3506 Abstract Predicting the worst-case execution time (WCET) of a real-time program is a challenging task. Though much progress has been made in obtaining tighter timing predic- tions by using techniques that model the architectural fea- tures of a machine, significant overestimations of WCET can still occur. Even with perfect architectural modeling, dependencies on data values can constrain the outcome of conditional branches and the corresponding set of paths that can be taken in a program. While value-dependent constraint information has been used in the past by some timing analyzers, it has typically been specified manually, which is both tedious and error prone. This paper describes efficient techniques for automatically detecting value-dependent constraints by a compiler and automati- cally exploiting these constraints within a timing analyzer. The result is tighter timing analysis predictions without requiring additional interaction with a user. 1. Introduction Obtaining accurate worst-case execution time (WCET) predictions of programs is a challenging task. Various fea- tures of the architecture, such as caches and pipelines, can affect the execution time of an instruction and these fea- tures need to be modeled while analyzing the control flow of a program. However, even with perfect architectural modeling, significant overestimations of WCET can still occur since dependencies on data values can constrain the outcome of conditional branches and restrict the set of paths that can be taken. While value-dependent constraint information has been used in the past by some timing ana- lyzers, it has typically been specified manually, which is both tedious and error prone. This paper describes how value-dependent constraints can be automatically detected by a compiler and exploited by a timing analyzer. 2. Related Work Some constraint-based timing analyzers use value- dependent constraints to obtain more accurate estimations of execution time. Li et al. performed timing analysis using an Implicit Path Enumeration (IPE) technique [1], which uses integer linear programming (ILP) to solve con- straints about the program to obtain timing predictions. Their technique automatically calculates program struc- tural constraints from the program control flow graph and used value-dependent constraints, which they called pro- gram functionality constraints. The work of Ottosson and Sjödin [2] extended the IPE technique by using finite domain constraints to model the architectural features of the hardware. However, in both approaches these value- dependent constraints were entered manually by the user, which is both a tedious and error-prone task. Recent work by Ermedahl and Gustafsson [3] and by Lundqvist and Stenström [4] use abstract interpretation and symbolic execution to automatically derive many value-dependent constraints. These approaches are quite powerful, but effectively requires simulating all paths of a loop for every loop iteration. Thus, these approaches require significant analysis overhead, which would be undesirable when analyzing long running programs. Another type of value-dependent constraint is the num- ber of loop iterations. We have implemented techniques to automatically determine the minimum and maximum iter- ations for many loops with multiple exit conditions and loops whose number of iterations depend on loop-invariant variables or counter variables of outer loops [5]. The abstract interpretation and symbolic execution approaches [3, 4] also provide a more powerful and less efficient method to calculate bounds on loop iterations. In this paper, we address detecting and exploiting value- dependent constraints that constrain execution paths rather than the number of iterations that a loop can execute. 3. Automatic Detection of Constraints A value-dependent constraint causes the outcome of a conditional branch to be known under certain conditions. We implemented techniques to detect these constraints, which we classified as effect-based and iteration-based. 3.1. Detecting Effect-Based Constraints The compiler performs analysis to determine if the out- come of a conditional branch is known at any given point