Skip to content

Commit

Permalink
[LoongArch64] fix the errors when reverse GT_JCC. (dotnet#85555)
Browse files Browse the repository at this point in the history
* [LoongArch64] fix the errors when reverse GT_JCC.

* just modify the LA64's files for CRs.
  • Loading branch information
shushanhf authored Apr 29, 2023
1 parent 6bb5449 commit b7d36a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5067,7 +5067,10 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
assert((tgtBlock->bbTgtStkDepth * sizeof(int) == genStackLevel) || isFramePointerUsed());
#endif // !FEATURE_FIXED_OUT_ARGS

emit->emitIns_J(INS_bcnez, tgtBlock, (int)1 /* cc */);
GenTreeCC* jcc = treeNode->AsCC();
assert(jcc->gtCondition.Is(GenCondition::EQ, GenCondition::NE));
instruction ins = jcc->gtCondition.Is(GenCondition::EQ) ? INS_bceqz : INS_bcnez;
emit->emitIns_J(ins, tgtBlock, (int)1 /* cc */);
}
break;

Expand Down
9 changes: 8 additions & 1 deletion src/coreclr/jit/lowerloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,20 @@ GenTree* Lowering::LowerJTrue(GenTreeOp* jtrue)

// LA64's float compare and condition-branch instructions, have
// condition flags indicating the comparing results.
// For LoongArch64, the floating compare result is saved to the specific register,
// where there are 8 bits for saveing at most eight different results, that is the FCC0 ~ FCC7.
// This is very different with the AArch64 and AMD64.
// For AArch64 and AMD64: | // For LoongArch64
// cmp $f1, $f2 <--just compare. | fcmp.cond cc,$f1,$f2 <--the condition is here.
// branch.condition <--the condition is here. | branch true or false by the cc flag.
if (varTypeIsFloating(cmpOp1))
{
op->gtType = TYP_VOID;
op->gtFlags |= GTF_SET_FLAGS;
assert(op->OperIs(GT_EQ, GT_NE, GT_LT, GT_LE, GT_GE, GT_GT));

jtrue->SetOper(GT_JCC);
jtrue->AsCC()->gtCondition = cond;
jtrue->AsCC()->gtCondition = GenCondition::NE; // For LA64 is only NE or EQ.
return nullptr;
}

Expand Down

0 comments on commit b7d36a8

Please sign in to comment.