Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
emit rorx only for long integers
  • Loading branch information
EgorBo committed Sep 9, 2020
commit 5a36432fdc46ea9470c5a2ccd109dec59243accb
11 changes: 5 additions & 6 deletions src/coreclr/src/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4083,16 +4083,15 @@ void CodeGen::genCodeForShift(GenTree* tree)
}
else
{
int typeWidth = genTypeSize(genActualType(targetType)) * 8;
int shiftByValue = (int)shiftBy->AsIntConCommon()->IconValue();

// Try to emit rorx if BMI2 is available instead of mov+rol
if (compiler->compOpportunisticallyDependsOn(InstructionSet_BMI2) && (tree->GetRegNum() != operandReg) &&
tree->OperIs(GT_ROL, GT_ROR) && (shiftByValue > 0) && (shiftByValue < typeWidth))
// it makes sense only for 64bit integers
if ((genActualType(targetType) == TYP_LONG) && (tree->GetRegNum() != operandReg) &&
compiler->compOpportunisticallyDependsOn(InstructionSet_BMI2) && tree->OperIs(GT_ROL, GT_ROR) &&
(shiftByValue > 0) && (shiftByValue < 64))
{
assert((typeWidth == 32) || (typeWidth == 64));

int value = tree->OperIs(GT_ROL) ? (typeWidth - shiftByValue) : shiftByValue;
const int value = tree->OperIs(GT_ROL) ? (64 - shiftByValue) : shiftByValue;
GetEmitter()->emitIns_R_R_I(INS_rorx, size, tree->GetRegNum(), operandReg, value);
}
else
Expand Down