Optimization Wanted

"Robert R. Hauser" <rrhauser@ingr.com>
9 Feb 1996 17:12:41 -0500

          From comp.compilers

Related articles
Optimization Wanted rrhauser@ingr.com (Robert R. Hauser) (1996-02-09)
Re: Optimization Wanted meissner@cygnus.com (Michael Meissner) (1996-02-14)
| List of all articles for this month |

From: "Robert R. Hauser" <rrhauser@ingr.com>
Newsgroups: comp.compilers
Date: 9 Feb 1996 17:12:41 -0500
Organization: Compilers Central
Keywords: C, optimize, question

Do any C compilers support the following optimization (below).


(Desc: I want to inline functions without introducing a forced
branch. See how the optimized codeflow races straight for the
return statement in 99.99% of the cases. This avoids branching
reduces the instruction cache consumption, etc, etc,).


Bob


Pre Optimized Codeflow:
    Func1() {
        status = somefunc()


        if (SUCCESS(status)) {
            status = Func2();


            if (SUCCESS(status)) {
                someotherfunc();
return STATUS_SUCCESS;
            }
            // error handling
        } else {
            // error handling
        }


        return status; // failure
    }


    Func2() {
        status = some3rdfunc();


        if (SUCCESS(status)) {
            // stuff
            return STATUS_SUCCESS;
        }
        // error handling
        return status; // failure
    }


Post-Optimization (inlined Func2)
    Func1() {
        status = somefunc()


        if (SUCCESS(status)) {
            status = some3rdfunc(); // INLINED FUNC2


            if (SUCCESS(status)) { // INLINED FUNC2
                // stuff // INLINED FUNC2
                someotherfunc();
return STATUS_SUCCESS;
            }
            // error handling for Func2 // INLINED FUNC2
            // error handling
        } else {
            // error handling
        }


        return status; // failure
    }
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.