BZ #22: src/vm/jit/loop/analyze.c(analyze_merge function)

Status fields:

creation_ts:2006-04-18 19:56
component:unspecified
version:0.95
rep_platform:All
op_sys:Linux
bug_status:RESOLVED
resolution:WONTFIX
reporter:yshi@cs.tcd.ie
The function below in the original code(src/vm/jit/loop/analyze.c) doesn't
perform correctly as it is intended to.

/*      This function is used to merge two loops with the same header together.
        A simple merge sort of the lists nodes of both loops is performed.
*/
void analyze_merge(struct LoopContainer *l1, struct LoopContainer *l2)
{
        struct LoopElement *start, *last, *le1, *le2, *ptr;
        /* start and last are pointers to the newly built list, le1 and le2 step  */
        /* step through the lists, that have to be merged.                        */

        le1 = l1->nodes;
        le2 = l2->nodes;

        /* start a simple merge sort of the nodes of both loops. These lists are  */
        /* already sorted, so merging is easy.                                    */
        if (le1->node < le2->node)
        {
                start = last = le1;
                le1 = le1->next;
        }
        else if (le1->node == le2->node)
        {
                start = last = le1;
                le1 = le1->next;
                le2 = le2->next;
        }
        else
        {
                assert(false);
                start = last = le2;
                le2 = le2->next;
        }

        /* while the first loop != NULL, depending of the first element of second */
        /* loop, add new node to result list                                      */
        while (le1 != NULL && le2 != NULL)
        {
                if (le1->node < le2->node)
                {
                        last->next = le1;
                        le1 = le1->next;
                }
                else if (le1->node == le2->node)
                {
                        last->next = le1;
                        le1 = le1->next;
                        le2 = le2->next;
                }
                else
                {
                        last->next = le2;
                        le2 = le2->next;
                }
                last = last->next;
        }

        if ( le1 == NULL)
        {
                last->next = le2;
        }
        else
        {
                last->next = le1;
        }
}

Comment #1 by twisti@complang.tuwien.ac.at on 2006-04-18 20:57:28

The loop optimization code is really unmaintained and outdated.  But we will
reactivate it when are implementing our optimization stuff.

Comment #2 by stefan@complang.tuwien.ac.at on 2011-01-20 22:28:45

Noone will touch that ever again.