diff --git a/src/coreclr/jit/codegenloongarch64.cpp b/src/coreclr/jit/codegenloongarch64.cpp index 01e82be425a3cc..0a1042ae1b1b0a 100644 --- a/src/coreclr/jit/codegenloongarch64.cpp +++ b/src/coreclr/jit/codegenloongarch64.cpp @@ -2418,7 +2418,7 @@ void CodeGen::genCodeForDivMod(GenTreeOp* tree) // Floating point divide never raises an exception assert(varTypeIsFloating(tree->gtOp1)); assert(varTypeIsFloating(tree->gtOp2)); - assert(tree->gtOper == GT_DIV); + assert(tree->OperIs(GT_DIV)); instruction ins = genGetInsForOper(tree); emit->emitIns_R_R_R(ins, emitActualTypeSize(targetType), tree->GetRegNum(), tree->gtOp1->GetRegNum(), @@ -2480,7 +2480,7 @@ void CodeGen::genCodeForDivMod(GenTreeOp* tree) } // check (MinInt / -1) => ArithmeticException - if (tree->gtOper == GT_DIV || tree->gtOper == GT_MOD) + if (tree->OperIs(GT_DIV, GT_MOD)) { if ((exSetFlags & ExceptionSetFlags::ArithmeticException) != ExceptionSetFlags::None) { @@ -2514,55 +2514,20 @@ void CodeGen::genCodeForDivMod(GenTreeOp* tree) // Generate the sdiv instruction if (size == EA_4BYTE) { - if (tree->OperGet() == GT_DIV) - { - ins = INS_div_w; - } - else - { - ins = INS_mod_w; - } + ins = tree->OperIs(GT_DIV) ? INS_div_w : INS_mod_w; } else { - if (tree->OperGet() == GT_DIV) - { - ins = INS_div_d; - } - else - { - ins = INS_mod_d; - } + ins = tree->OperIs(GT_DIV) ? INS_div_d : INS_mod_d; } emit->emitIns_R_R_R(ins, size, tree->GetRegNum(), Reg1, divisorReg); } - else // if (tree->gtOper == GT_UDIV) GT_UMOD + else // tree->OperIs(GT_UDIV, GT_UMOD) { - // Only one possible exception - // (AnyVal / 0) => DivideByZeroException - // - // Note that division by the constant 0 was already checked for above by the - // op2->IsIntegralConst(0) check - // - - if (!divisorOp->IsCnsIntOrI()) - { - // divisorOp is not a constant, so it could be zero - // - genJumpToThrowHlpBlk_la(SCK_DIV_BY_ZERO, INS_beq, divisorReg); - } - if (size == EA_4BYTE) { - if (tree->OperGet() == GT_UDIV) - { - ins = INS_div_wu; - } - else - { - ins = INS_mod_wu; - } + ins = tree->OperIs(GT_UDIV) ? INS_div_wu : INS_mod_wu; // TODO-LOONGARCH64: here is just for signed-extension ? emit->emitIns_R_R_I(INS_slli_w, EA_4BYTE, Reg1, Reg1, 0); @@ -2570,14 +2535,7 @@ void CodeGen::genCodeForDivMod(GenTreeOp* tree) } else { - if (tree->OperGet() == GT_UDIV) - { - ins = INS_div_du; - } - else - { - ins = INS_mod_du; - } + ins = tree->OperIs(GT_UDIV) ? INS_div_du : INS_mod_du; } emit->emitIns_R_R_R(ins, size, tree->GetRegNum(), Reg1, divisorReg); diff --git a/src/coreclr/jit/emitloongarch64.cpp b/src/coreclr/jit/emitloongarch64.cpp index 86ba90fa36eded..6aaf00a973c8a7 100644 --- a/src/coreclr/jit/emitloongarch64.cpp +++ b/src/coreclr/jit/emitloongarch64.cpp @@ -4,7 +4,7 @@ /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX -XX emitloongarch64.cpp XX +XX emitloongarch64.cpp XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX