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
33 changes: 33 additions & 0 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,22 @@ bool emitter::HasRegularWideImmediateForm(instruction ins)
return (flags & INS_FLAGS_Has_Sbit) != 0;
}

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

//------------------------------------------------------------------------
// DoesWriteZeroFlag: check if the instruction write the
// ZF flag.
Expand Down Expand Up @@ -1472,6 +1488,23 @@ bool emitter::AreFlagsSetToZeroCmp(regNumber reg, emitAttr opSize, GenCondition
}
}

if ((cond.GetCode() == GenCondition::SLT) || (cond.GetCode() == GenCondition::SGE))
{
if (DoesWriteSignFlag(lastIns) && DoesWriteOverflowFlag(lastIns) && IsFlagsAlwaysModified(id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (DoesWriteSignFlag(lastIns) && DoesWriteOverflowFlag(lastIns) && IsFlagsAlwaysModified(id))
if (DoesResetOverflowFlag(lastIns) && DoesWriteSignFlag(lastIns) && IsFlagsAlwaysModified(id))

{
return id->idOpSize() == opSize;
}
}

if ((cond.GetCode() == GenCondition::SGT) || (cond.GetCode() == GenCondition::SLE))
{
if (DoesWriteZeroFlag(lastIns) && DoesWriteSignFlag(lastIns) && DoesWriteOverflowFlag(lastIns) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (DoesWriteZeroFlag(lastIns) && DoesWriteSignFlag(lastIns) && DoesWriteOverflowFlag(lastIns) &&
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 @@ -767,6 +767,7 @@ bool IsDstSrcSrcAVXInstruction(instruction ins) const;
bool IsThreeOperandAVXInstruction(instruction ins) const;
static bool HasRegularWideForm(instruction ins);
static bool HasRegularWideImmediateForm(instruction ins);
static bool DoesWriteOverflowFlag(instruction ins);
static bool DoesWriteZeroFlag(instruction ins);
static bool DoesWriteParityFlag(instruction ins);
static bool DoesWriteSignFlag(instruction ins);
Expand Down
Loading