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
Position of constant folded operand in or-statement affects codegen #123621
In the code below, placing the comparison with Environment.NewLine inline after a non-runtime constant check produces extra code compared to hoisting the newline check to a local, or placing it first.
I'd like to work on this and submit a PR. From my initial investigation, the constant folding itself works correctly in all three cases (the Environment.NewLine check is fully eliminated). The difference is that in the Inline_After case, the remaining BBJ_COND block with v == 2 isn't being simplified into a branchless return (sete/movzx), unlike the Hoisted and Inline_Before cases. I plan to enable JITDUMP to trace exactly where the optimization gap occurs — likely around fgFoldCondToReturnBlock or the block compaction between morph and optOptimizeBools.
Please let me know if there are any pointers or context I should be aware of before diving in.
Activity
yykkibbb commentedon Feb 20, 2026
Hi @EgorBo @JulieLeeMSFT, thank you for triaging this issue!
I'd like to work on this and submit a PR. From my initial investigation, the constant folding itself works correctly in all three cases (the
Environment.NewLinecheck is fully eliminated). The difference is that in theInline_Aftercase, the remainingBBJ_CONDblock withv == 2isn't being simplified into a branchless return (sete/movzx), unlike theHoistedandInline_Beforecases. I plan to enable JITDUMP to trace exactly where the optimization gap occurs — likely aroundfgFoldCondToReturnBlockor the block compaction between morph andoptOptimizeBools.Please let me know if there are any pointers or context I should be aware of before diving in.
JIT: Fix fgFoldCondToReturnBlock for multi-statement return blocks (d…
Move test to JIT/opt/OptimizeBools per review feedback (dotnet#123621)
Move test to JIT/opt/OptimizeBools per review feedback (dotnet#123621)
JIT: Fix VN-based dead store removal for unused SSA defs (dotnet#123621)
JIT: Fix VN-based dead store removal for unused SSA defs (dotnet#123621)
JIT: Fix VN-based dead store removal for unused SSA defs (dotnet#123621)
Revert VN-based dead store removal changes per review feedback (dotne…
JIT: Fix fgFoldCondToReturnBlock for multi-statement return blocks (d…
JIT: Fix fgFoldCondToReturnBlock for multi-statement return blocks (#…