Skip to content

LSRA Reg Optional: Folding of operations using a tree temp #6863

@sivarv

Description

@sivarv

Say we have the following expr

a = (b + (c + (d+ (e+f))))

in LIR form

t0 = e+f
t1 = t0+d
t2 = t1+c
a = t2+b

Say it is profitable to not to allocate a reg to Use position of '+' in (e+f). That is tree temp t0 needs to be spilled to memory. Furthermore it is profitable to not to allocate a reg to both use and def positions of '+' in (t0+d) and (t1+c)

Since all of these tree temps are not live at the same time, using a single tree temp, we can generate the following

reg = e+f
spill reg to stack location given by spill tmp1
add [addr of tmp1], reg of d
add [add or tmp1], reg of c
mov a'reg, b's reg
add a'reg, [addr of tmp1]

To perform such an optimization, LSRA would need to annotate a tree node with a spill temp number that codegen is supposed to use for spill/reload purposes.

category:cq
theme:register-allocator
skill-level:expert
cost:medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsoptimizationtenet-performancePerformance related issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions