Skip to content

[loops] Should "unswitch" trivial conditions #1079

@lattner

Description

@lattner
Bugzilla Link 707
Resolution FIXED
Resolved on Feb 22, 2010 12:45
Version 1.0
OS All

Extended Description

Consider this simple case:

void test(int N, int* P) {
int i, j;
for (j = 0; j < N; ++j)
for (i = 0; i < N; ++i)
P[i+j] = 0;
}

The inner loop does a comparison of N against 0 to see if it should enter the inner loop. This test is
invariant in the outer loop (and even shared) so it is hoisted. Despite this, we still do the comparison
each time through the outer loop. If the comparison can't succeed, and if the outer loop does no other
work, we should do a trivial unswitch on that value.

This is particularly important if the outer loop has many more iterations than the inner loop, such as in
173.applu and other programs.

-Chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillacode-qualityenhancementImproving things as opposed to bug fixing, e.g. new or missing featureloopoptim

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions