You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unnecessary sign-extension for some never-negative expressions #119680
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors
I'd be happy to take a look at this if no one else is on it.
If I'm reading it right, IntegralRange::ForNode doesn't handle GT_UDIV/GT_RSZ/GT_RSH. The division is still UDIV(tzcnt, 2) at morph time, so this check in fgOptimizeCast fails and the sign-extend stays:
Thanks for the pointer! I took a look, and I think they're separate, though I might be wrong. #132450 seems to handle cast round trips like CAST(long <- CAST(int <- X)), while here there's only a single cast over UDIV(tzcnt, 2), and ForNode doesn't seem to know that's non-negative. So I'd expect the cdqe to still be there with that change, but I'll double-check.
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors
Activity
dotnet-policy-service commentedon Sep 13, 2025
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
p6laris commentedon Sep 27, 2026
I'd be happy to take a look at this if no one else is on it.
If I'm reading it right,
IntegralRange::ForNodedoesn't handleGT_UDIV/GT_RSZ/GT_RSH. The division is stillUDIV(tzcnt, 2)at morph time, so this check infgOptimizeCastfails and the sign-extend stays:runtime/src/coreclr/jit/morph.cpp
Line 8582 in 33baf8e
I was thinking of adding those cases to
ForNode, unless there's a better place for it that I'm missing.xtqqczze commentedon Sep 27, 2026
Might be worth checking whether this overlaps with #132450.
p6laris commentedon Sep 27, 2026
Thanks for the pointer! I took a look, and I think they're separate, though I might be wrong. #132450 seems to handle cast round trips like
CAST(long <- CAST(int <- X)), while here there's only a single cast overUDIV(tzcnt, 2), andForNodedoesn't seem to know that's non-negative. So I'd expect thecdqeto still be there with that change, but I'll double-check.p6laris commentedon Sep 27, 2026
@xtqqczze Double-checked: with #132450 applied,
M1still emits thecdqe, so I opened #134739 for this one.