Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 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
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ class CodeGen final : public CodeGenInterface
void inst_JMP(emitJumpKind jmp, BasicBlock* tgtBlock);
#endif

void inst_SET(emitJumpKind condition, regNumber reg);
void inst_SET(emitJumpKind condition, regNumber reg, insOpts instOptions = INS_OPTS_NONE);

void inst_RV(instruction ins, regNumber reg, var_types type, emitAttr size = EA_UNKNOWN);

Expand Down
24 changes: 18 additions & 6 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1807,19 +1807,29 @@ void CodeGen::inst_SETCC(GenCondition condition, var_types type, regNumber dstRe
assert(varTypeIsIntegral(type));
assert(genIsValidIntReg(dstReg) && isByteReg(dstReg));

const GenConditionDesc& desc = GenConditionDesc::Get(condition);
const GenConditionDesc& desc = GenConditionDesc::Get(condition);
insOpts instOptions = INS_OPTS_NONE;

inst_SET(desc.jumpKind1, dstReg);
bool needsMovzx = !varTypeIsByte(type);
if (needsMovzx && compiler->canUseApxEvexEncoding() && JitConfig.EnableApxZU())
{
instOptions = INS_OPTS_EVEX_zu;
needsMovzx = false;
}

inst_SET(desc.jumpKind1, dstReg, instOptions);

if (desc.oper != GT_NONE)
{
BasicBlock* labelNext = genCreateTempLabel();
inst_JMP((desc.oper == GT_OR) ? desc.jumpKind1 : emitter::emitReverseJumpKind(desc.jumpKind1), labelNext);
inst_SET(desc.jumpKind2, dstReg);
inst_SET(desc.jumpKind2, dstReg, instOptions);
genDefineTempLabel(labelNext);
}

if (!varTypeIsByte(type))
// we can apply EVEX.ZU to avoid this movzx.
// TODO-XArch-apx: evaluate setcc + movzx and xor + set
if (needsMovzx)
{
GetEmitter()->emitIns_Mov(INS_movzx, EA_1BYTE, dstReg, dstReg, /* canSkip */ false);
}
Expand Down Expand Up @@ -9450,6 +9460,8 @@ void CodeGen::genAmd64EmitterUnitTestsApx()

theEmitter->emitIns_Mov(INS_movd32, EA_4BYTE, REG_R16, REG_XMM0, false);
theEmitter->emitIns_Mov(INS_movd32, EA_4BYTE, REG_R16, REG_XMM16, false);

theEmitter->emitIns_R(INS_seto_apx, EA_1BYTE, REG_R11, INS_OPTS_EVEX_zu);
}

void CodeGen::genAmd64EmitterUnitTestsAvx10v2()
Expand Down Expand Up @@ -10351,7 +10363,7 @@ void CodeGen::genPushCalleeSavedRegisters()
#endif // DEBUG

#ifdef TARGET_AMD64
if (compiler->canUseApxEncoding() && compiler->canUseEvexEncoding() && JitConfig.EnableApxPPX())
if (compiler->canUseApxEvexEncoding() && JitConfig.EnableApxPPX())
{
genPushCalleeSavedRegistersFromMaskAPX(rsPushRegs);
return;
Expand Down Expand Up @@ -10477,7 +10489,7 @@ void CodeGen::genPopCalleeSavedRegisters(bool jmpEpilog)
return;
}

if (compiler->canUseApxEncoding() && compiler->canUseEvexEncoding() && JitConfig.EnableApxPPX())
if (compiler->canUseApxEvexEncoding() && JitConfig.EnableApxPPX())
{
regMaskTP rsPopRegs = regSet.rsGetModifiedIntCalleeSavedRegsMask();
const unsigned popCount = genPopCalleeSavedRegistersFromMaskAPX(rsPopRegs);
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9678,6 +9678,17 @@ class Compiler
return compOpportunisticallyDependsOn(InstructionSet_APX);
}

//------------------------------------------------------------------------
// canUseApxEvexEncoding - Answer the question: Are APX-EVEX encodings supported on this target.
//
// Returns:
// `true` if APX-EVEX encoding is supported, `false` if not.
//
bool canUseApxEvexEncoding() const
{
return canUseApxEncoding() && canUseEvexEncoding();
}

private:
//------------------------------------------------------------------------
// DoJitStressEvexEncoding- Answer the question: Do we force EVEX encoding.
Expand Down
15 changes: 15 additions & 0 deletions src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,8 @@ class emitter

#define _idEvexbContext (_idCustom6 << 1) | _idCustom5 /* Evex.b: embedded broadcast, rounding, SAE */
#define _idEvexNdContext _idCustom5 /* bits used for the APX-EVEX.nd context for promoted legacy instructions */
#define _idEvexZuContext _idCustom5 /* bits used for the APX-EVEX.zu context for promoted legacy instructions */

#define _idEvexNfContext _idCustom6 /* bits used for the APX-EVEX.nf context for promoted legacy/vex instructions */

// We repurpose 4 bits for the default flag value bits for ccmp instructions.
Expand Down Expand Up @@ -1793,15 +1795,28 @@ class emitter

bool idIsEvexNdContextSet() const
{
assert(IsApxNddCompatibleInstruction(_idIns));
return _idEvexNdContext != 0;
}

bool idIsEvexZuContextSet() const
{
assert(IsApxZuCompatibleInstruction(_idIns));
return (_idEvexZuContext != 0);
}

void idSetEvexNdContext()
{
assert(!idIsEvexNdContextSet());
_idEvexNdContext = 1;
}

void idSetEvexZuContext()
{
assert(!idIsEvexZuContextSet());
_idEvexZuContext = 1;
}

bool idIsEvexNfContextSet() const
{
return _idEvexNfContext != 0;
Expand Down
Loading
Loading