Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

BruceForstall
Copy link

Reduce the differences between x86 and AMD64 codegen to reduce the number of #ifdefs. This changes AMD64 codegen for initialized locallocs by using the x86 style "dec" loop instead of "sub rsp,16". Saves one byte of code size per instance. I ran all standard internal testing on this change.

@sivarv PTAL
cc @dotnet/jit-contrib

// push_hide means don't track the stack
inst_IV(INS_push_hide, 0);
cntPtrSizedWords--;
inst_IV(INS_push_hide, 0); // push_hide means don't track the stack

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An extra comment might be nice here - we're not tracking the stack because the stack tracking is updated separately for localloc, or ...?

@CarolEidt
Copy link

LGTM with just a couple of comment suggestions.

@sivarv
Copy link
Member

sivarv commented Jul 14, 2016

Looks good.

// Align to STACK_ALIGN
// regCnt will be the total number of bytes to localloc
inst_RV_IV(INS_add, regCnt, (STACK_ALIGN - 1), emitActualTypeSize(type));
// Align the number of bytes to allocate to STACK_ALIGN.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should read more like "Round up to the number of bytes to the next higher STACK_ALIGN "

@briansull
Copy link

LGTM with comments

@sivarv
Copy link
Member

sivarv commented Jul 14, 2016

@briansull - Is this change applicable to Arm64 implementation of genLclHeap()? More specifically, if we have a smaller instruction to decrement a register, we can use that instead of "sub reg, 16" by converting regCnt to loop-iteration count for compInitMem case.

@BruceForstall
Copy link
Author

I added / improved a bunch of comments per suggestions

@briansull
Copy link

There aren't any "smaller" instructions on ARM64.
If you are reading/writing a memory location you can subsume the increment or decrement into the addressing mode to same an instruction. (Post-Inc or Pre-Dec, etc..)
The increment/decrement a register instruction is add/sub with a 12-bit constant.

@BruceForstall BruceForstall merged commit e8bdf3e into dotnet:master Jul 14, 2016
@BruceForstall BruceForstall deleted the LocAllocCleanup branch July 14, 2016 18:40
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…anup

Clean up localloc implementation

Commit migrated from dotnet/coreclr@e8bdf3e
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants