Improvement of Iterative Algorithm for Live Variable Analysis based on Computation Reordering

사용할 변수의 예측에 사용되는 반복적 알고리즘의 계산순서 재정렬을 통한 수행 속도 개선

  • 윤정한 (한국과학기술원 전산학과) ;
  • 한태숙 (한국과학기술원 전산학과)
  • Published : 2005.08.01

Abstract

The classical approaches for computing Live Variable Analysis(LVA) use iterative algorithms across the entire programs based on the Data Flow Analysis framework. In case of Zephyr compiler, average execution time of LVA takes $7\%$ of the compilation time for the benchmark programs. The classical LVA algorithm has many aspects for improvement. The iterative algorithm for LVA scans useless basic blocks and calculates large sets of variables repeatedly. We propose the improvement of Iterative algorithm for LVA based on used variables' upward movement. Our algorithm produces the same result as the previous iterative algorithm. It is based on use-def chain. Reordering of applying the flow equation in DFA reduces the number of visiting basic blocks and redundant flow equation executions, which improves overall processing time. Experimental results say that our algorithm ran reduce $36.4\%\;of\;LVA\;execution\;time\;and\;2.6\%$ of overall computation time in Zephyr compiler with benchmark programs.

기존의 LVA를 수행하는 알고리즘은 반복적 정보흐름분석(Iterative Data Flow Analysis -DFA) 프레임워크에 따라 프로그램 전체를 반복적으로 스캔하면서 진행되어진다. Zephyr[1] 컴파일러의 경우 이와 같은 반복적 알고리즘으로 LVA를 수행하는 시간이 전체 컴파일 시간에서 약 $7\%$를 차지하고 있다. 기존 LVA 알고리즘은 여러 가지로 개선할 점들이 있다. LVA를 수행하는 기존의 반복적 알고리즘은 알고리즘의 특성상 방문하지 않아도 되는 basic block들에 대한 방문이 잦고, 살아있는 변수들의 집합을 점차적으로 증가해 가면서 구하는 특성상 큰 변수들의 집합에 대한 연산을 계속 하게 된다. 우리는 기존의 알고리즘과 달리 사용된 변수들(USE set)에 대해 Control Flow Graph(CFG)에서 거슬러 올라가면서 LVA를 수행하는 반복적인 알고리즘의 개선안을 제안하고자 한다. 이는 기존의 알고리즘과 같은 결과를 내면서 더 빠른 알고리즘이다. DFA에서의 flow equation을 적용하는 순서를 바꿈으로써 많은 중복 계산을 줄일 수 있다. 이러한 방법으로 인해 basic block을 방문해야만 하는 횟수를 줄이면서 전체 수행 시간을 단축시킨다. 간단한 추가 구현만으로 Zephyr 컴파일러에서의 실험 결과에서 LVA만을 수행하는 시간에서 기존의 알고리즘보다 $36.4\%$ 짧은 시간을 사용하였고, 이는 전체 컴파일 시간을 $2.6\%$ 줄이는 효과를 가져왔다.

Keywords

References

  1. Zephyr Homepage http://www.cs.virginia.edu/zephyr/ May 1999
  2. Wankang Zhao, Baosheng Cai, et al. VISTA: A System for Interactive Code Improvement. In Proceddings of Language, Compilers, and Tools for Embedded Systems, 2002 https://doi.org/10.1145/566225.513857
  3. Massimiliano Poletto and Vivek Sarkar. Linear Scan Register Allocation. In ACM Transactions on Programming Languages and Systems, 21(5) pages 895-913, September 1999 https://doi.org/10.1145/330249.330250
  4. Zoran Budimlic, Keith D. Cooper, and Timothy J. Harvey. Fast Copy Coalescing and Live-Range Identification. In SIGPLAN Conference on Programming Language Design and Implementation, pages 25-32, 2002 https://doi.org/10.1145/512529.512534
  5. Keith D. Cooper, Timothy J. Harvey, and Linda Torczon. How to Build an Interference Graph. In Software-Practice and Experience, VOL. 1(1), 1, January 1988 https://doi.org/10.1002/(SICI)1097-024X(19980410)28:4<425::AID-SPE160>3.0.CO;2-2
  6. J. B. Kam and J. D. Ullman. Monotone data flow analysis frameworks. In Acta Informatica, 7(3) pages 305-317, July 1977 https://doi.org/10.1007/BF00290339
  7. Susan L. Graham, Mark N. Wegman. A Fast and Usually Linear Algorithm for Global Flow Analysis. JACM 23(1): 172-202, 1976 https://doi.org/10.1145/321921.321939
  8. C. Samuel Hsieh. A fine-grained data-flow analysis framework. In Acta Informatica, 34(9) pages 653-665, August 1997 https://doi.org/10.1007/s002360050101
  9. A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles. Techniques. and Tools. Addison-Wesley, Reading. MA, 1986
  10. Evelyn Duesterwald. Rajiv Gupta. and Mary Lou Soffa. Reducing the Cost of Data Flow Analysis By Congruence Partitioning. In International Conference on Compiler Construction, April 1994
  11. Michael P. Gerlek, Michael Wolfe, and Eric Stoltz. A Reference Chain Approach for Live Variables. Technical Report CSE 94-029, Oregon Graduate Institute, April 1994
  12. Glenn Ammons and James R. Larus. Improving Data-flow Analysis with Path Profiles. In Proceedings of the SIGPLAN Conference on Programming Language Design and Implementation, pages 72-84, 1998 https://doi.org/10.1145/277650.277665
  13. S. W. K. Tjiang and J. L. Hennessy. Sharlit: A tool for builing optimizers, In SIGPLAN Conference on Programming Language Design and Implementation, pages 82-93, 1992 https://doi.org/10.1145/143103.143120
  14. MediaBench Homepage http://www.cs.ucla.edu/-leec/mediabench/