dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.99k stars 4.67k forks source link

Improve and unify the handling of addressing modes in RyuJIT #6041

Open CarolEidt opened 8 years ago

CarolEidt commented 8 years ago

There are several issues with the handling of addressing modes:

We should do the analysis once in the front-end and instantiate the addressing modes at that time, and should strongly consider factoring the analysis out from the code generation, which is currently enabled or disabled by an argument to genCreateAddrMode().

category:cq theme:big-bets skill-level:expert cost:large

TIHan commented 10 months ago
#ifdef TARGET_XARCH
        if (BlockRange().TryGetUse(node, &use))
        {
            // If this is a child of an ordinary indir, let the parent handle it.
            // If there is a chain of adds, only look at the topmost one.
            GenTree* parent = use.User();
            if ((!parent->OperIsIndir() || parent->OperIsAtomicOp()) && !parent->OperIs(GT_ADD))
            {
                TryCreateAddrMode(node, false, parent);
            }
        }
#endif // TARGET_XARCH

TryCreateAddrMode will do the analysis to see if it can create an address mode:

    // Find out if an addressing mode can be constructed
    bool doAddrMode = comp->codeGen->genCreateAddrMode(addr,     // address
                                                       true,     // fold
                                                       &rev,     // reverse ops
                                                       &base,    // base addr
                                                       &index,   // index val
                                                       &scale,   // scaling
                                                       &offset); // displacement

Improvements can still be made here it looks like, though a bit uncertain of how much effort would be needed and the benefit.