Fix RangeOps::Multiply to handle dependent ranges#124533
Merged
Conversation
Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Copilot
AI
changed the title
[WIP] Fix RangeOps::Multiply regression for dependent ranges
Fix RangeOps::Multiply to handle dependent ranges
Feb 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates CoreCLR JIT range analysis to avoid immediately giving up on RangeOps::Multiply when inputs are not fully constant, aiming to preserve range propagation for induction-variable patterns and prevent ARM64 CSieve perf regressions.
Changes:
- Adjusted
RangeOps::Multiplyto return a range that preserveskeDependenton non-constant inputs instead of always returningkeUnknown. - Kept existing constant-range multiply behavior (including overflow checks) unchanged.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Member
|
PTAL @jakobbotsch @dotnet/jit-contrib fix for a perf regression. Restores back the previous logic to propagate keDependent for MUL. |
jakobbotsch
approved these changes
Feb 19, 2026
iremyux
pushed a commit
to iremyux/dotnet-runtime
that referenced
this pull request
Mar 2, 2026
## Description
`RangeOps::Multiply` was returning `keUnknown` when either range had
dependent bounds, preventing range propagation for loop induction
variables. This caused a ~12% regression in CSieve on ARM64.
## Changes
Modified `RangeOps::Multiply` in `src/coreclr/jit/rangecheck.h`:
- Preserve existing behavior for fully constant ranges
- For ranges with dependent bounds: check if constant bound combinations
overflow, then return dependent range (not `keUnknown`)
- Aligns with `Add`/`Subtract` patterns for dependent bound handling
Enables JIT to maintain range information for patterns like:
```csharp
for (int k = i + i; k <= Size; k += i)
{
array[k] = value; // Can now optimize bounds checks
}
```
## Validation
Run CSieve benchmark with EgorBot to confirm regression fix.
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `https://api.github.com/graphql`
> - Triggering command: `/usr/bin/gh gh issue view 124349 --json
title,body,comments --jq {title, body, comments: [.comments[].body]}`
(http block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/dotnet/runtime/settings/copilot/coding_agent)
(admins only)
>
> </details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Co-authored-by: Egor Bogatov <egorbo@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
RangeOps::Multiplywas returningkeUnknownwhen either range had dependent bounds, preventing range propagation for loop induction variables. This caused a ~12% regression in CSieve on ARM64.Changes
Modified
RangeOps::Multiplyinsrc/coreclr/jit/rangecheck.h:keUnknown)Add/Subtractpatterns for dependent bound handlingEnables JIT to maintain range information for patterns like:
Validation
Run CSieve benchmark with EgorBot to confirm regression fix.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/usr/bin/gh gh issue view 124349 --json title,body,comments --jq {title, body, comments: [.comments[].body]}(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.