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

x86: support Return SIMD8. #46899

Merged
merged 5 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
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
43 changes: 36 additions & 7 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ void CodeGen::genCodeForMul(GenTreeOp* treeNode)
}

#ifdef FEATURE_SIMD

//------------------------------------------------------------------------
// genSIMDSplitReturn: Generates code for returning a fixed-size SIMD type that lives
// in a single register, but is returned in multiple registers.
Expand All @@ -1148,34 +1149,62 @@ void CodeGen::genSIMDSplitReturn(GenTree* src, ReturnTypeDesc* retTypeDesc)
regNumber reg0 = retTypeDesc->GetABIReturnReg(0);
regNumber reg1 = retTypeDesc->GetABIReturnReg(1);

assert((reg0 != REG_NA) && (reg1 != REG_NA) && (opReg != REG_NA));

const bool srcIsFloatReg = genIsValidFloatReg(opReg);
const bool dstIsFloatReg = genIsValidFloatReg(reg0);
assert(srcIsFloatReg);

#ifdef TARGET_AMD64
assert(src->TypeIs(TYP_SIMD16));
assert(srcIsFloatReg == dstIsFloatReg);
if (opReg != reg0 && opReg != reg1)
{
// Operand reg is different from return regs.
// Copy opReg to reg0 and let it to be handled by one of the
// two cases below.
inst_RV_RV(ins_Copy(TYP_DOUBLE), reg0, opReg, TYP_DOUBLE);
inst_RV_RV(ins_Copy(opReg, TYP_SIMD16), reg0, opReg, TYP_SIMD16);
opReg = reg0;
}

if (opReg == reg0)
{
assert(opReg != reg1);

// reg0 - already has required 8-byte in bit position [63:0].
// reg1 = opReg.
// swap upper and lower 8-bytes of reg1 so that desired 8-byte is in bit position [63:0].
inst_RV_RV(ins_Copy(TYP_DOUBLE), reg1, opReg, TYP_DOUBLE);
inst_RV_RV(ins_Copy(opReg, TYP_SIMD16), reg1, opReg, TYP_SIMD16);
}
else
{
assert(opReg == reg1);

// reg0 = opReg.
// swap upper and lower 8-bytes of reg1 so that desired 8-byte is in bit position [63:0].
inst_RV_RV(ins_Copy(TYP_DOUBLE), reg0, opReg, TYP_DOUBLE);

inst_RV_RV(ins_Copy(opReg, TYP_SIMD16), reg0, opReg, TYP_SIMD16);
}
// reg0 - already has required 8-byte in bit position [63:0].
// swap upper and lower 8-bytes of reg1 so that desired 8-byte is in bit position [63:0].
inst_RV_RV_IV(INS_shufpd, EA_16BYTE, reg1, reg1, 0x01);

#else // TARGET_X86
assert(src->TypeIs(TYP_SIMD8));
assert(srcIsFloatReg != dstIsFloatReg);
assert((reg0 == REG_EAX) && (reg1 == REG_EDX));
// reg0 = opReg[31:0]
inst_RV_RV(ins_Copy(opReg, TYP_INT), reg0, opReg, TYP_INT);
// reg1 = opRef[61:32]
if (compiler->compExactlyDependsOn(InstructionSet_SSE41))
{
inst_RV_RV_IV(INS_pextrd, EA_4BYTE, reg1, opReg, 1);
}
else
{
int8_t shuffleMask = 1; // we only need [61:32]->[31:0], the rest is not read.
GetEmitter()->emitIns_R_R_I(INS_pshufd, EA_8BYTE, opReg, opReg, shuffleMask);
sandreenko marked this conversation as resolved.
Show resolved Hide resolved
inst_RV_RV(ins_Copy(opReg, TYP_INT), reg1, opReg, TYP_INT);
}
#endif // TARGET_X86
}

#endif // FEATURE_SIMD

#if defined(TARGET_X86)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8821,7 +8821,7 @@ void emitter::emitDispIns(
}
else if (ins == INS_mov_xmm2i)
{
printf("%s, %s", emitRegName(id->idReg2(), attr), emitRegName(id->idReg1(), EA_16BYTE));
printf("%s, %s", emitRegName(id->idReg1(), attr), emitRegName(id->idReg2(), EA_16BYTE));
}
else if (ins == INS_pmovmskb)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ void CodeGen::inst_RV_RV_IV(instruction ins, emitAttr size, regNumber reg1, regN
{
assert(ins == INS_shld || ins == INS_shrd || ins == INS_shufps || ins == INS_shufpd || ins == INS_pshufd ||
ins == INS_cmpps || ins == INS_cmppd || ins == INS_dppd || ins == INS_dpps || ins == INS_insertps ||
ins == INS_roundps || ins == INS_roundss || ins == INS_roundpd || ins == INS_roundsd);
ins == INS_roundps || ins == INS_roundss || ins == INS_roundpd || ins == INS_roundsd || ins == INS_pextrd);
sandreenko marked this conversation as resolved.
Show resolved Hide resolved

GetEmitter()->emitIns_R_R_I(ins, size, reg1, reg2, ival);
}
Expand Down