Skip to content

optimize for affine values #216

@pca006132

Description

@pca006132

For SDFs like the metaballs where $r_i, p_i$ are the radius and the center for the ball $i$, and $g$ be some interpolation from 0 to 1:

$$f(p) = \sum_i g(r_i - \left\vert p - p_i \right\vert )$$

Oftentimes the interpolation function will be capped at 0 or 1, making some of the summands constants. However, currently there is no way to partially evaluate this and collapse those constant summands.

To optimize for this kind of situation, we can try to track affine values, e.g. $r * c_1 + c_2$ where $r$ is a register and $c_1, c_2$ are constants. We can mark some instructions like $r_3 = r_1 + r_2$ as dead if either $r_1$ or $r_2$ is a constant, or they are both affine values with the same register. And we can later convert this result back to an interval when necessary, i.e. when an instruction that does not produce an affine value takes it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions