Skip to content

Commit

Permalink
Add helper method for Resets OF/CF flags
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalspathak committed Jun 1, 2021
1 parent 53c4325 commit 7ded469
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ bool emitter::IsWriteZFFlags(instruction ins)
return (CodeGenInterface::instInfo[ins] & INS_FLAGS_WritesZF) != 0;
}

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

//------------------------------------------------------------------------
// IsFlagsModified: check if the instruction modifies the flags.
Expand Down Expand Up @@ -195,7 +209,6 @@ bool emitter::IsFlagsModified(instrDesc* id)
return false;
default:
return true;

}
}
}
Expand Down Expand Up @@ -348,8 +361,7 @@ bool emitter::AreFlagsSetToZeroCmp(regNumber reg, emitAttr opSize, genTreeOps tr
return false;
}

// these always set OF and CF to 0
if ((lastIns == INS_and) || (lastIns == INS_or) || (lastIns == INS_xor))
if (IsResetsOCFlags(lastIns))
{
return id->idOpSize() == opSize;
}
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 @@ -172,6 +172,7 @@ void SetContains256bitAVX(bool value)
bool IsDstDstSrcAVXInstruction(instruction ins);
bool IsDstSrcSrcAVXInstruction(instruction ins);
bool IsWriteZFFlags(instruction ins);
bool IsResetsOCFlags(instruction ins);
bool IsFlagsModified(instrDesc* id);

bool IsThreeOperandAVXInstruction(instruction ins)
Expand Down

0 comments on commit 7ded469

Please sign in to comment.