BUG in SUIF2 nci/suif/suif2b/basepasses/transforms/region_passes.cpp

Kristof Beyls Kristof.Beyls@elis.rug.ac.be
Fri, 24 Dec 1999 12:13:15 +0100 (CET)


1. 
There seems to be a bug in the CFor2ForPass code.

At line 363 in nci/suif/suif2b/basepasses/transforms/region_passes.cpp:

    ...
    // make sure step is an index increment
    // done is 2 steps:
    //  tmp = i
    //  i = tmp + 1
    if(!is_kind_of<StatementList>(step)) return false;
    StatementList* list = to<StatementList>(step);
    ...

The comments say that the only possible form of an index increment is
// tmp = i
// i = tmp + 1

Actually another form is also possible:
// tmp = i + 1
// i = tmp

This form is triggered from source code like:
    /* This loop generates the second form */
    for(i=5;i<20;i+=2)
	/* This loop generates the original form */
        for(j=10;j<100;j++)


2.
Another disadvantage of this CFor2ForPass is that anotations are not
maintained. For example:

#pragma tile
for(int i=0; i<10; i++)
   for(int j=0; j<10; j++)

looses the pragma if CFor2ForPass is executed on this code. It seems quite
easy to make sure that this annotation is maintained through the
conversion. I've implemented it be changing the original code on line 462:

    cfor->get_parent()->replace(cfor, for_stmt);
    // TODO: do we need to trash cfor here somehow?
    return true;

into:

    cfor->get_parent()->replace(cfor, for_stmt);

    // Copy the annotations from cfor to for
    for(Iter<Annote*> i=cfor->get_annote_iterator();
          i.is_valid(); i.next())
	for_stmt->append_annote(to<Annote>(i.current()->deep_clone()));
    
    // TODO: do we need to trash cfor here somehow?
    return true;


With kind regards,
Kristof Beyls 

--------------------------------------------------------------------
Parallel Information Systems 	Tel: +32(9)2648910
Universiteit Gent       	Fax: +32(9)2643594
St.-Pietersnieuwstraat 41 	E-mail: Kristof.Beyls@elis.rug.ac.be
B-9000 Gent, Belgium		
--------------------------------------------------------------------