Search Results for 'compiler optimization'

1 POSTS

  1. 2006.09.18 Strength Reduction

Strength Reduction

Posted 2006. 9. 18. 01:19
strength reduction은 타겟 머신에서 무거운(expensive) 연산을 가벼운(cheap) 연산으로 바꾸는 컴파일러 최적화 기법을 말한다. 쉬운 예로, 곱하기 연산을 더하기 연산으로 바꾸는 경우를 들 수 있다.

썬 마이크로시스템즈에서 나온 다음 논문(
Operator Strength Reduction)에 자세한 설명이 있다.

Operator strength reduction is a technique that improves compiler-generated code by reformulating
certain costly computations in terms of less expensive ones. A common case arises in array
addressing expressions used in loops. The compiler can replace the sequence of multiplies generated
by a direct translation of the address expression with an equivalent sequence of additions.


구체적인 예로는

for i from 1 to n do
   z= i*x
  ...
end

위와 같은 코드를 다음과 같이 바꿔 주는 것이다.

z=0;
for i from 1 to n do
  z=z+x
  ..
end