Skip to content

Fixed transformations bugs, upgrade packages, and more.#1292

Merged
tgiphil merged 13 commits into
mosa:masterfrom
tgiphil:610-bisector
May 13, 2026
Merged

Fixed transformations bugs, upgrade packages, and more.#1292
tgiphil merged 13 commits into
mosa:masterfrom
tgiphil:610-bisector

Conversation

@tgiphil

@tgiphil tgiphil commented May 13, 2026

Copy link
Copy Markdown
Member

This pull request introduces several important improvements and corrections across the codebase, focusing on IR transformation accuracy, compiler optimization logic, build process updates, and documentation. The main changes are grouped below.

IR Transformations and Optimizations

  • Corrected double extension IR optimizations to preserve the correct extension operation, replacing previous incorrect simplifications to Move instructions with the appropriate ZeroExtend or SignExtend IR instructions in both the JSON optimization definitions and auto-generated transform files. This ensures semantic correctness for cases like IR.ZeroExtend8x32(IR.ZeroExtend8x32 a) and similar patterns. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

  • Disabled three manual transforms related to ZeroExtend8x32Compare32x32 and similar patterns, pending further validation, to avoid potential incorrect optimizations.

Compiler Analysis and Transform Hook Logic

  • Refined integer operation handling in SparseConditionalConstantPropagation.cs for better type correctness, especially for 32-bit operations, and to ensure correct masking and casting for all arithmetic and bitwise operations. [1] [2]

  • Removed unnecessary transform hook registration and checks for block transforms in BaseTransformStage, simplifying the transform application logic. [1] [2]

Build System Updates

  • Updated the Windows build workflow to use dotnet pack for .csproj files instead of nuget pack, and removed the legacy NuGet environment variable, modernizing the package creation process. [1] [2] [3]

Documentation

  • Added documentation for the new -postfix command-line argument and the corresponding FilePostfix setting, and clarified the usage of SearchPaths. [1] [2]

These changes collectively improve the correctness of IR optimizations, streamline the build process, and enhance documentation for users and developers.

tgiphil added 9 commits May 10, 2026 15:41
Add CurrentDisabledTransforms property to BisectorState to record the list of currently disabled transforms. Update ExecuteIteration to set this property before saving state, ensuring the state file accurately reflects the active transform configuration for each iteration.
Eliminated duplicate registration of block transforms with compiler hooks in Initialize(). Also removed per-transform disabled checks in ApplyBlockTransforms() for a more streamlined and consistent transform application process.
Introduced a new "FilePostfix" setting and command-line argument ("-postfix") to allow users to append a custom postfix to the base output filename. Updated the argument map, MOSASettings, and filename resolution logic to support this feature. Added a corresponding constant in the Name class.
Removed legacy NuGet env var and consolidated Mosa.Templates build and packaging into a single dotnet pack step. This modernizes the CI process and simplifies package output management.
Introduce `-postfix` and `-path` command-line arguments for customizing output file names and search paths. Update documentation to describe these options and add `FilePostfix` to the settings table. Add related constants in `Name.cs` and clarify platform argument documentation. Also, append new unit test-related constants.
Update double zero/sign-extend IR transforms to emit the correct extend instruction instead of Move, ensuring proper extension semantics. Comment out certain "useless" ZeroExtend compare transforms in ManualTransforms.cs.
Refactored IntegerOperation1 and IntegerOperation to handle 32-bit and 64-bit instructions in separate branches. Ensured proper casting and masking for 32-bit results and applied correct shift masks. Improves correctness and clarity, especially for edge cases and overflows.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates MOSA’s optimization/transform pipeline and tooling by fixing incorrect “double extension” simplifications in IR optimizations, refining SCCP integer folding for 32-bit correctness, modernizing parts of the Windows packaging workflow, and adding a new output filename postfix setting (plus some QEMU packaging updates and docs).

Changes:

  • Fix “double extend” useless transforms to keep the correct ZeroExtend*/SignExtend* IR op instead of incorrectly collapsing to Move.
  • Improve SCCP integer operation folding (32-bit masking/casting, shift masking) and simplify transform hook logic in BaseTransformStage.
  • Add -postfix / FilePostfix setting, update docs, update Avalonia package versions, and update Windows packaging + QEMU tooling assets.

Reviewed changes

Copilot reviewed 27 out of 53 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
Tools/reduce-qemu.bat Update QEMU installer URL and prune additional DLLs/files from the reduced bundle.
Tools/qemu/VERSION Bump recorded QEMU version.
Source/Mosa.Utility.UnitTestBisector/UnitTestBisectorSystem.cs Persist current disabled transform set into state during iteration execution.
Source/Mosa.Utility.UnitTestBisector/BisectorState.cs Add CurrentDisabledTransforms to persisted bisector state.
Source/Mosa.Utility.Configuration/Name.cs Add FilePostfix setting key constant.
Source/Mosa.Utility.Configuration/MOSASettings.cs Add FilePostfix setting and apply it to derived output filenames.
Source/Mosa.Utility.Configuration/CommandLineArguments.cs Add -postfix CLI argument mapping.
Source/Mosa.Tool.Launcher/Mosa.Tool.Launcher.csproj Bump Avalonia package versions.
Source/Mosa.Tool.Explorer.Avalonia/Mosa.Tool.Explorer.Avalonia.csproj Bump Avalonia package versions.
Source/Mosa.Tool.Bootstrap/Mosa.Tool.Bootstrap.csproj Bump Avalonia package versions.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/ManualTransforms.cs Disable a few manual transforms pending validation.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend8x64Double.cs Adjust double-zero-extend optimization to preserve ZeroExtend* semantics.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend8x32Double.cs Adjust double-zero-extend optimization to preserve ZeroExtend* semantics.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend32x64Double.cs Adjust double-zero-extend optimization to preserve ZeroExtend* semantics.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend16x64Double.cs Adjust double-zero-extend optimization to preserve ZeroExtend* semantics.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/ZeroExtend16x32Double.cs Adjust double-zero-extend optimization to preserve ZeroExtend* semantics.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend8x64Double.cs Adjust double-sign-extend optimization to preserve SignExtend* semantics.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend8x32Double.cs Adjust double-sign-extend optimization to preserve SignExtend* semantics.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend32x64Double.cs Adjust double-sign-extend optimization to preserve SignExtend* semantics.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend16x64Double.cs Adjust double-sign-extend optimization to preserve SignExtend* semantics.
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/Useless/SignExtend16x32Double.cs Adjust double-sign-extend optimization to preserve SignExtend* semantics.
Source/Mosa.Compiler.Framework/Stages/BaseTransformStage.cs Remove transform-hook registration/disable checks for block transforms.
Source/Mosa.Compiler.Framework/Analysis/SparseConditionalConstantPropagation.cs Refine integer folding logic (especially 32-bit masking/casting and shift masking).
Source/Docs/settings-options.rst Document FilePostfix setting.
Source/Docs/command-line-arguments.rst Document -postfix and adjust CLI argument listing.
Source/Data/IR-Optimizations-Useless.json Fix useless optimization outputs for “double extension” patterns to preserve correct extend ops.
.github/workflows/builds.yml Switch Mosa.Templates packaging to dotnet pack and remove legacy env var.

Comment thread Tools/reduce-qemu.bat Outdated
Comment thread Source/Docs/command-line-arguments.rst Outdated
Comment thread Source/Mosa.Utility.Configuration/MOSASettings.cs
Comment thread Source/Mosa.Compiler.Framework/Stages/BaseTransformStage.cs
Comment thread Source/Docs/command-line-arguments.rst Outdated
tgiphil added 4 commits May 12, 2026 21:22
Replaced 'random-combo' with 'random' in bisector docs, CLI, and code. Clarified comments for managed pointer memory transforms. Enabled additional 'Useless' transforms. Fixed Add32 manual transform to check next.Result register for ESP.
Corrected a typo in the batch script by changing `del /S /Q qemu\share\u-boot-sam460.binS` to the correct file name `del /S /Q qemu\share\u-boot-sam460.bin`, ensuring the intended file is deleted. No other changes were made.

Update CLI docs formatting; fix typo in reduce-qemu.bat

Reordered and clarified command-line argument documentation, including a new "Compiler - Platform" section. Fixed a minor typo in reduce-qemu.bat affecting the u-boot-sam460.bin deletion command.
Only iterate transforms when AllowTransformHooks is true, avoiding unnecessary iteration and improving efficiency. Logic for null-checking and hook registration is unchanged.
Renamed the variable resultOperand to result for improved clarity and consistency within the Transform method. Updated all references accordingly.
@tgiphil tgiphil merged commit c422664 into mosa:master May 13, 2026
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants