Skip to content

Commit

Permalink
Furture reduce the TP cost
Browse files Browse the repository at this point in the history
Moved the *= operators as instance of `regMaskTP` so the `.low`
private field can directly be manipulated instead of converting
the `64-bit` value in `regMaskTP` before doing any operation.

Overall: 0.74%
MinOpts: 0.82%
FullOpts: 0.68%
  • Loading branch information
kunalspathak committed May 29, 2024
1 parent b3218e1 commit ccddf1c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ inline regNumber genFirstRegNumFromMaskAndToggle(SingleTypeRegSet& mask)

/* Convert the mask to a register number */

regNumber regNum = (regNumber)BitScanForward(mask);
regNumber regNum = (regNumber)BitOperations::BitScanForward(mask);

mask ^= genRegMask(regNum);

Expand Down
48 changes: 22 additions & 26 deletions src/coreclr/jit/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ struct regMaskTP
public:
regMaskTP(regMaskSmall regMask)
: low(regMask)
{

{
}

regMaskTP()
Expand Down Expand Up @@ -323,6 +322,27 @@ struct regMaskTP
void RemoveRegNumFromMask(regNumber reg);

bool IsRegNumInMask(regNumber reg);


void operator|=(const regMaskTP& second)
{
low |= second.getLow();
}

void operator^=(const regMaskTP& second)
{
low ^= second.getLow();
}

void operator^=(const regNumber reg)
{
low ^= genRegMask(reg);
}

void operator&=(const regMaskTP& second)
{
low &= second.getLow();
}
};

static regMaskTP operator^(const regMaskTP& first, const regMaskTP& second)
Expand All @@ -343,30 +363,6 @@ static regMaskTP operator|(const regMaskTP& first, const regMaskTP& second)
return result;
}

static regMaskTP& operator|=(regMaskTP& first, const regMaskTP& second)
{
first = first | second;
return first;
}

static regMaskTP& operator^=(regMaskTP& first, const regMaskTP& second)
{
first = first ^ second;
return first;
}

static regMaskTP& operator^=(regMaskTP& first, const regNumber reg)
{
first = first ^ genRegMask(reg);
return first;
}

static regMaskTP& operator&=(regMaskTP& first, const regMaskTP& second)
{
first = first & second;
return first;
}

static bool operator==(const regMaskTP& first, const regMaskTP& second)
{
return (first.getLow() == second.getLow());
Expand Down

0 comments on commit ccddf1c

Please sign in to comment.