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] X64 - Three instruction replacement sequence for multiply in certain cases #76981

Merged
merged 25 commits into from
Oct 20, 2022
Merged
Changes from 4 commits
Commits
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
13 changes: 13 additions & 0 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,19 @@ void CodeGen::genCodeForMul(GenTreeOp* treeNode)

inst_RV_SH(INS_shl, size, targetReg, shiftAmount);
}
#ifdef TARGET_AMD64
else if (!requiresOverflowCheck && rmOp->isUsedFromReg() && (imm <= 127) && isPow2(imm + 1))
{
uint64_t zextImm = static_cast<uint64_t>(static_cast<size_t>(imm + 1));
unsigned int shiftAmount = genLog2(zextImm );

inst_Mov(targetType, targetReg, rmOp->GetRegNum(), /* canSkip */ false);
TIHan marked this conversation as resolved.
Show resolved Hide resolved

inst_RV_SH(INS_shl, size, targetReg, shiftAmount);

GetEmitter()->emitIns_R_R(INS_sub, emitTypeSize(treeNode->gtType), targetReg, rmOp->GetRegNum());
}
#endif
else
{
// use the 3-op form with immediate
Expand Down