Repository navigation
[Codegen][CPU] Keep roundeven native where LLVM lowers it to instructions - #25219
Merged
Merged
Conversation
…tructions MathTransform has expanded `math.roundeven` into a software sequence on every target except ROCm and WebGPU since 68439a0 on every llvm-cpu target. Most CPU targets actually have an intruction: FRINTN on AArch64, ROUNDPS/ROUNDPD on x86 with SSE4.1, FCVT on riscv64 with D extension. Since `math.roundeven` affects a lot of float-to-int quantization cases, so it makes sense to use instructions and not software sequences wherever possible. Tests: - New lit cases cover each target used in the check - Numerical results are identical to before the change for f32 and f64, checked on x86, AArch64 (QEMU) and riscv64 hardware (SpacemiT K3). Assisted-By: Claude Code Signed-off-by: Zmicier Prybysh <[email protected]>
dimp-pl
requested review from
AGindinson,
egebeysel and
phemashekar
as code owners
November 6, 2026 13:13
AGindinson
reviewed
Nov 6, 2026
Signed-off-by: Zmicier Prybysh <[email protected]>
AGindinson
reviewed
Nov 6, 2026
AGindinson
left a comment
Contributor
There was a problem hiding this comment.
Generally looks good, I'd suggest expanding testing coverage
Check the expanded sequence in the emulated math_transform cases, and add an end-to-end test under LLVMCPU/test that compiles roundeven for aarch64, x86-64 (SSE4.1, AVX2) and riscv64 (D, V) and checks the assembly for the native instructions. Signed-off-by: Zmicier Prybysh <[email protected]>
dimp-pl
requested review from
Manewing,
devtbi and
jschuhmacher
as code owners
November 6, 2026 18:01
AGindinson
enabled auto-merge (squash)
November 9, 2026 08:56
devtbi
added a commit
that referenced
this pull request
Nov 11, 2026
…arget (#25234) The tests - early_data_tiling.mlir, early_data_tiling_convolution.mlir, early_data_tiling_dynamic.mlir, added in #24969 - roundeven_native.mlir, added in #25219 (also riscv64), compile for aarch64. byo_llvm.sh builds LLVM with only the X86 target, so iree-compile stops with "createTargetMachine(...) failed" and the tests fail linux_x64_clang_byollvm job. Add these tests in the same way as #25221: CMake adds them only if iree_compiler_targeting_iree_arch() is true for their architecture. Theaarch64 and riscv64 RUN lines move into *_aarch64.mlir and *_riscv64.mlir files, which copy the IR. ci-extra: linux_x64_clang_byollvm --------- Signed-off-by: Tobias Fuchs <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
8 tasks done
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.
MathTransform has expanded
math.roundeveninto a software sequence on every target except ROCm and WebGPU since 68439a0 on every llvm-cpu target.Most CPU targets actually have an intruction: FRINTN on AArch64, ROUNDPS/ROUNDPD on x86 with SSE4.1, FCVT on riscv64 with D extension.
Since
math.roundevenaffects a lot of float-to-int quantization cases, so it makes sense to use instructions and not software sequences wherever possible.Tests:
Related issue: #12778.
Assisted-By: Claude Code