     Next: loop interchanging Up: Simple functions Previous: Loop distribution

## Loop fusion

The loop fusion transformation moves the body of a do-loop statement in another do-loop statement. Example 63:

```    DO I=1,N
PRINT *,I
ENDDO
DO I=1,N
A[I] = F(I)+1
ENDDO
``` ```    DO I=1,N
PRINT *,I
A[I] = F(I)+1
ENDDO
``` Fits:LoopFusion:Check(LOOP DIAGMESG LOOP2)

This function check if the fusion of two do-loop statements is allowed.
• LOOP (input AST) must be the first do-loop statement.
• DIAGMESG (output STRING) is a diagnostic string for the user.
• LOOP2 (input AST) must be the second do-loop statement.
• The function returns an error code (return INT):
• 1 if all is correct
• 0 if LOOP is not a do-loop statement
• -1 if LOOP contains statements not handled by the transformation.
• -2 if LOOP2 is not a do-loop statement
• -3 if LOOP2 contains statements not handled by the transformation.
• -4 if the bounds or the steps of LOOP and LOOP2 are not compatibles.
• -5 if LOOP and LOOP2 are not in the same sequence of statements Fits:LoopFusion:Advice(LOOP DIAGMESG LOOP2)

This function emits a diagnostic about the interest of the fusion of LOOP2 into LOOP.
• LOOP (input AST) must be a do-loop statement.
• DIAGMESG (output STRING) is a diagnostic string for the user.
• LOOP2 (input AST) must be the second do-loop statement.
• The function returns a diagnostic code (return INT) :
• 1 if the transformation is recommended.
• 0 if the transformation may be interesting.
• -1 if the transformation in not recommended. Fits:LoopFusion:Safe(LOOP,DIAGMESG,LOOP2)

This functions check if the fusion of LOOP2 in LOOP is safe.
• LOOP (input AST) must be a do-loop statement.
• DIAGMESG (output STRING) is a diagnostic string for the user
• LOOP2 (input AST) must be the second do-loop statement.
• The function returns a diagnostic code (return INT) :
• 1 if the transformation is safe
• 0 if the transformation may be safe. More informations are given by the text in DIAGMESG.
• -1 if the transformation is not safe Fits:LoopFusion:Apply(LOOP,VERBOSE,LOOP2)

This function applies the loop fusion transformation.
• LOOP (input AST) must be a do-loop statement.
• VERBOSE (input INT) is the comment level
• LOOP2 (input AST) must be the second do-loop statement.
• The function returns the do-loop statement created by the fusion (return AST)     Next: loop interchanging Up: Simple functions Previous: Loop distribution
Yann Mevel
1999-04-30