Closed germanium32 closed 1 year ago
Implement Add2Sum. Traverse over add instructions, and check whether if it is chained to a simple addition operation. That is:
Add2Sum
res = a + b + c + d + e
will be transformed into ll by iterated additions, such as the form:
%0 = add %a, %b %1 = add %0, %c %2 = add %1, %d %res = add %2, %e
which then can be optimized in the form:
%res = call sum(%a, %b, %c, %d, %e, 0, 0, 0)
Reverse traverse all instructions, and find propagating tree of add instructions. Since the internal nodes will be all removed, other uses of such instructions must exist.
Overview
Implement
Add2Sum
. Traverse over add instructions, and check whether if it is chained to a simple addition operation. That is:will be transformed into ll by iterated additions, such as the form:
which then can be optimized in the form:
Implementation
Reverse traverse all instructions, and find propagating tree of add instructions. Since the internal nodes will be all removed, other uses of such instructions must exist.