Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JIT] Optimization for left-shift operator #52297

Closed
wants to merge 32 commits into from
Closed
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2c7d76e
Fix bool-check call and add nullptr
DarkBullNull Apr 24, 2021
47517a7
Add lvar dataSize
DarkBullNull Apr 24, 2021
7b2a14a
Remove type def
DarkBullNull Apr 24, 2021
0ee8295
Move def dataSize
DarkBullNull Apr 25, 2021
49fd837
Update codegen.h
DarkBullNull Apr 25, 2021
3a542a4
Update compiler.h
DarkBullNull Apr 25, 2021
0d38ce3
Rename "dataSize" to "eDataSize" (EmitDataSize)
DarkBullNull Apr 25, 2021
dd96487
Grammar fix compiler.h
DarkBullNull Apr 26, 2021
52c08c6
Grammar fix
DarkBullNull Apr 29, 2021
2da9735
Add files via upload
DarkBullNull May 4, 2021
eb88fee
Update codegenxarch.cpp
DarkBullNull May 4, 2021
54cf11d
Update morph.cpp
DarkBullNull May 4, 2021
8fd2375
Update codegenxarch.cpp
DarkBullNull May 4, 2021
3ef0e24
Update morph.cpp
DarkBullNull May 4, 2021
512daa7
Update codegenxarch.cpp
DarkBullNull May 5, 2021
e20628e
Merge branch 'main' into runtime6.3_test
DarkBullNull May 5, 2021
e973f62
Update codegenarm64.cpp
DarkBullNull May 5, 2021
e32ab33
Update morph.cpp
DarkBullNull May 5, 2021
ce9db99
Update morph.cpp
DarkBullNull May 5, 2021
44330b1
Update compiler.h
DarkBullNull May 5, 2021
400a360
Update gentree.cpp
DarkBullNull May 5, 2021
9589f2c
Update compiler.cpp
DarkBullNull May 5, 2021
f782919
Update codegencommon.cpp
DarkBullNull May 5, 2021
744ed90
Update codegencommon.cpp
DarkBullNull May 5, 2021
4415518
Update codegenxarch.cpp
DarkBullNull May 5, 2021
6f5bd46
Update compiler.cpp
DarkBullNull May 5, 2021
a529be4
Update compiler.cpp
DarkBullNull May 5, 2021
5247e6f
Update compiler.h
DarkBullNull May 5, 2021
acb2d4c
Fix comments
DarkBullNull May 5, 2021
cd0a7fd
fix formatting
DarkBullNull May 5, 2021
c0f4d7a
intCon to IsIntegralConst()
DarkBullNull May 14, 2021
08f4152
Merge branch 'dotnet:main' into runtime6.3_test
DarkBullNull Nov 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4214,15 +4214,29 @@ void CodeGen::genCodeForShift(GenTree* tree)
emitAttr size = emitTypeSize(tree);

// Optimize "X<<1" to "lea [reg+reg]" or "add reg, reg"
if (tree->OperIs(GT_LSH) && !tree->gtOverflowEx() && !tree->gtSetFlags() && shiftBy->IsIntegralConst(1))
// Optimize "X<<2" to "lea [reg*4]"
// Optimize "X<<3" to "lea [reg*8]"
if (tree->OperIs(GT_LSH) && !tree->gtOverflowEx() && !tree->gtSetFlags() &&
(shiftBy->IsIntegralConst(1) || shiftBy->IsIntegralConst(2) || shiftBy->IsIntegralConst(3)))
{
if (tree->GetRegNum() == operandReg)
if (shiftBy->IsIntegralConst(1))
{
GetEmitter()->emitIns_R_R(INS_add, size, tree->GetRegNum(), operandReg);
if (tree->GetRegNum() == operandReg)
{
GetEmitter()->emitIns_R_R(INS_add, size, tree->GetRegNum(), operandReg);
}
else
{
GetEmitter()->emitIns_R_ARX(INS_lea, size, tree->GetRegNum(), operandReg, operandReg, 1, 0);
}
}
else if (shiftBy->IsIntegralConst(2))
{
GetEmitter()->emitIns_R_AX(INS_lea, size, tree->GetRegNum(), operandReg, 4, 0);
}
else
{
GetEmitter()->emitIns_R_ARX(INS_lea, size, tree->GetRegNum(), operandReg, operandReg, 1, 0);
GetEmitter()->emitIns_R_AX(INS_lea, size, tree->GetRegNum(), operandReg, 8, 0);
}
}
else
Expand Down