Repository: dotnet/runtime
File: src/coreclr/jit/stacklevelsetter.cpp (C++)

Code before:
        case GT_BOUNDS_CHECK:
        {
            GenTreeBoundsChk* bndsChk = node->AsBoundsChk();
            SetThrowHelperBlock(bndsChk->gtThrowKind, block);
        }
        break;

#if defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH)
        case GT_HWINTRINSIC:
        {

            NamedIntrinsic intrinsicId = node->AsHWIntrinsic()->GetHWIntrinsicId();
            if (intrinsicId == NI_Vector128_op_Division || intrinsicId == NI_Vector256_op_Division)
            {
                SetThrowHelperBlock(SCK_DIV_BY_ZERO, block);
                SetThrowHelperBlock(SCK_OVERFLOW, block);
            }
        }
        break;
#endif // defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH)

        case GT_ARR_ELEM:
            // Should not exist after morph.
            assert(!"GT_ARR_ELEM should not exist after morph");
            break;

        case GT_INDEX_ADDR:
            if (node->AsIndexAddr()->IsBoundsChecked())
            {
                SetThrowHelperBlock(SCK_RNGCHK_FAIL, block);
            }
            break;

        case GT_CKFINITE:
            SetThrowHelperBlock(SCK_ARITH_EXCPN, block);
            break;

#if defined(TARGET_ARM64) || defined(TARGET_ARM) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
        case GT_DIV:
        case GT_UDIV:
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
        case GT_MOD:
        case GT_UMOD:
#endif
        {
            ExceptionSetFlags exSetFlags = node->OperExceptions(m_compiler);

            if ((exSetFlags & ExceptionSetFlags::DivideByZeroException) != ExceptionSetFlags::None)
            {
                SetThrowHelperBlock(SCK_DIV_BY_ZERO, block);
            }

Review comment (suggestion):
I would recommend removing this assert here and adding `DBK_NOTLIR` to the node definition in `gtlist.h` instead.

Code after:
        case GT_BOUNDS_CHECK:
        {
            GenTreeBoundsChk* bndsChk = node->AsBoundsChk();
            SetThrowHelperBlock(bndsChk->gtThrowKind, block);
        }
        break;

#if defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH)
        case GT_HWINTRINSIC:
        {

            NamedIntrinsic intrinsicId = node->AsHWIntrinsic()->GetHWIntrinsicId();
            if (intrinsicId == NI_Vector128_op_Division || intrinsicId == NI_Vector256_op_Division)
            {
                SetThrowHelperBlock(SCK_DIV_BY_ZERO, block);
                SetThrowHelperBlock(SCK_OVERFLOW, block);
            }
        }
        break;
#endif // defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH)

        case GT_INDEX_ADDR:
            if (node->AsIndexAddr()->IsBoundsChecked())
            {
                SetThrowHelperBlock(SCK_RNGCHK_FAIL, block);
            }
            break;

        case GT_CKFINITE:
            SetThrowHelperBlock(SCK_ARITH_EXCPN, block);
            break;

#if defined(TARGET_ARM64) || defined(TARGET_ARM) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
        case GT_DIV:
        case GT_UDIV:
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
        case GT_MOD:
        case GT_UMOD:
#endif
        {
            ExceptionSetFlags exSetFlags = node->OperExceptions(m_compiler);

            if ((exSetFlags & ExceptionSetFlags::DivideByZeroException) != ExceptionSetFlags::None)
            {
                SetThrowHelperBlock(SCK_DIV_BY_ZERO, block);
            }
            else
            {
                // Even if we thought it might divide by zero during morph, now we know it never will.
                node->gtFlags |= GTF_DIV_MOD_NO_BY_ZERO;
            }