Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
32 changes: 32 additions & 0 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,21 @@ bool emitter::DoesWriteSignFlag(instruction ins)
return (flags & Writes_SF) != 0;
}

//------------------------------------------------------------------------
// DoesResetOverflowFlag: check if the instruction resets the OF flag to 0.
//
// Arguments:
// ins - instruction to test
//
// Return Value:
// true if instruction resets the OF flag, false otherwise.
//
bool emitter::DoesResetOverflowFlag(instruction ins)
{
insFlags flags = CodeGenInterface::instInfo[ins];
return (flags & Resets_OF) == Resets_OF;
}

//------------------------------------------------------------------------
// DoesResetOverflowAndCarryFlags: check if the instruction resets the
// OF and CF flag to 0.
Expand Down Expand Up @@ -1472,6 +1487,23 @@ bool emitter::AreFlagsSetToZeroCmp(regNumber reg, emitAttr opSize, GenCondition
}
}

if ((cond.GetCode() == GenCondition::SLT) || (cond.GetCode() == GenCondition::SGE))
{
if (DoesResetOverflowFlag(lastIns) && DoesWriteSignFlag(lastIns) && IsFlagsAlwaysModified(id))
{
return id->idOpSize() == opSize;
}
}

if ((cond.GetCode() == GenCondition::SGT) || (cond.GetCode() == GenCondition::SLE))
{
if (DoesResetOverflowFlag(lastIns) && DoesWriteZeroFlag(lastIns) && DoesWriteSignFlag(lastIns) &&
IsFlagsAlwaysModified(id))
{
return id->idOpSize() == opSize;
}
}

return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/emitxarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ static bool HasRegularWideImmediateForm(instruction ins);
static bool DoesWriteZeroFlag(instruction ins);
static bool DoesWriteParityFlag(instruction ins);
static bool DoesWriteSignFlag(instruction ins);
static bool DoesResetOverflowFlag(instruction ins);
static bool DoesResetOverflowAndCarryFlags(instruction ins);
bool IsFlagsAlwaysModified(instrDesc* id);
static bool IsRexW0Instruction(instruction ins);
Expand Down
Loading