[opt](expr) use compiler builtin for int128 multiplication overflow checks - #66476
Open
Mryange wants to merge 1 commit into
Open
[opt](expr) use compiler builtin for int128 multiplication overflow checks#66476Mryange wants to merge 1 commit into
Mryange wants to merge 1 commit into
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: Replace division-based signed int128 multiplication overflow detection with __builtin_mul_overflow. The previous implementation generated an expensive 128-bit division helper on the decimal multiplication path, while the compiler builtin lowers to inline arithmetic on x86-64. In the Decimal64 by Decimal128 query-like benchmark, CPU time decreased from 21.32 ns/item to 6.32 ns/item, a 70.34% reduction. Boundary combinations and deterministic random inputs are checked against an Int256 oracle.
### Release note
None
### Check List (For Author)
- Test: Manual test
- Release benchmark build: sh build.sh --benchmark -j48
- Benchmark correctness validation against Int256 oracle
- Generated-code inspection
- clang-format 16 check
- Behavior changed: No
- Does this need documentation: No
Mryange
force-pushed
the
opt-int128-mul-overflow
branch
from
August 5, 2026 09:47
a19d9c2 to
f07206d
Compare
Contributor
Author
|
run buildall |
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.
What problem does this PR solve?
Checked
int128multiplication used a division-based software implementation. On x86-64, thisgenerated a call to the expensive
__udivti3helper in the decimal multiplication path.This change uses
__builtin_mul_overflow, allowing the compiler to emit inline multiplication andcarry instructions without a runtime helper call. It also adds boundary coverage and 10,000
deterministic random input pairs that validate both the overflow flag and low 128 result bits against
an
Int256oracle.For the query-like
DECIMAL64(10,7) * DECIMAL128(38,2) -> DECIMAL128(38,9)benchmark with 65,536items per batch, using aggregate CPU mean from five repetitions:
Release note
None
Check List (For Author)
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)