Skip to content

Commit

Permalink
Merge pull request #3541 from alyssarosenzweig/opt/clc
Browse files Browse the repository at this point in the history
optimize clc
  • Loading branch information
alyssarosenzweig authored Apr 1, 2024
2 parents f2d001e + b64a594 commit b1ddd8c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion FEXCore/Source/Interface/Core/JIT/Arm64/ALUOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ DEF_OP(RmifNZCV) {
auto Op = IROp->C<IR::IROp_RmifNZCV>();
LOGMAN_THROW_A_FMT(CTX->HostFeatures.SupportsFlagM, "Unsupported flagm op");

rmif(GetReg(Op->Src.ID()).X(), Op->Rotate, Op->Mask);
rmif(GetZeroableReg(Op->Src).X(), Op->Rotate, Op->Mask);
}

DEF_OP(SetSmallNZV) {
Expand Down
15 changes: 15 additions & 0 deletions FEXCore/Source/Interface/IR/Passes/ConstProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,21 @@ bool ConstProp::ConstantInlining(IREmitter *IREmit, const IRListView& CurrentIR)

break;
}
case OP_RMIFNZCV:
{
auto Op = IROp->C<IR::IROp_RmifNZCV>();

uint64_t Constant1{};
if (IREmit->IsValueConstant(Op->Header.Args[0], &Constant1)) {
if (Constant1 == 0) {
IREmit->SetWriteCursor(CurrentIR.GetNode(Op->Header.Args[0]));
IREmit->ReplaceNodeArgument(CodeNode, 0, CreateInlineConstant(IREmit, 0));
Changed = true;
}
}

break;
}
case OP_CONDADDNZCV:
{
auto Op = IROp->C<IR::IROp_CondAddNZCV>();
Expand Down
5 changes: 2 additions & 3 deletions unittests/InstructionCountCI/FlagM/Primary.json
Original file line number Diff line number Diff line change
Expand Up @@ -2353,11 +2353,10 @@
]
},
"clc": {
"ExpectedInstructionCount": 2,
"ExpectedInstructionCount": 1,
"Comment": "0xf8",
"ExpectedArm64ASM": [
"mov w20, #0x0",
"rmif x20, #63, #nzCv"
"rmif xzr, #63, #nzCv"
]
},
"stc": {
Expand Down

0 comments on commit b1ddd8c

Please sign in to comment.