# [LLVMdev] IR Passes and TargetTransformInfo: Straw Man

Shuxin Yang shuxin.llvm at gmail.com
Wed Jul 31 19:24:10 PDT 2013

```Return from work, now I access O64's src, excerpt bellow, FYI:

cat -n be/lno/forward.h

94 ***   In backward substitution, we look for statements of the form
95 ***   "array = scalar", and backward substitute the scalar references
96 ***   if some of them occur in a deeper loop and the array reference
97 ***   is not reassigned over the life of the scalar's equivalence
class.
98 ***   This lets us transform the following:
99 ***
100 ***     subroutine fs(a, b, c, n)
101 ***     integer i, j, k, n
102 ***     real s, a(n,n), b(n,n), c(n,n)
103 ***     do i = 1, n
104 ***       do j = 1, n
105 ***        s = c(i,j)
106 ***        do k = 1, n
107 ***           s = s + a(i,k) * b(k,j)
108 ***        end do
109 ***        c(i,j) = s
110 ***      end do
111 ***     end do
112 ***     end
113 ***
114 ***   into:
115 ***
116 ***     subroutine fs(a, b, c, n)
117 ***     integer i, j, k, n
118 ***     real s, a(n,n), b(n,n), c(n,n)
119 ***     do i = 1, n
120 ***       do j = 1, n
121 ***        do k = 1, n
122 ***           c(i,j) = c(i,j) + a(i,k) * b(k,j)
123 ***        end do
124 ***      end do
125 ***     end do
126 ***     end

>>
>>>
>>> Normal loop:
>>>
>>> for i
>>>    for j
>>>      sum[i] += A[i][j]
>>>
>>> LICM loop:
>>>
>>> for i
>>>    s = sum[i]
>>>    for j
>>>      s += A[i][j]
>>>    sum[i] = s
>>>
>>>

```