Skip to content

Unify charconv umul128 with shared _Base128 implementation - #6355

Closed
DAVID RINALDI (notedavidrinaldi) wants to merge 1 commit into
microsoft:mainfrom
notedavidrinaldi:issue-6352-unify-umul128
Closed

Unify charconv umul128 with shared _Base128 implementation#6355
DAVID RINALDI (notedavidrinaldi) wants to merge 1 commit into
microsoft:mainfrom
notedavidrinaldi:issue-6352-unify-umul128

Conversation

@notedavidrinaldi

Copy link
Copy Markdown

Closes #6352

Summary

This change removes duplicated 128-bit multiply fallback logic in xcharconv by reusing the existing shared implementation in _Base128.

  • In stl/inc/xcharconv_ryu.h, include __msvc_int128.hpp so __ryu_umul128 can call _Base128::_UMul128.
  • Replace the manual non-intrinsic fallback multiply code in __ryu_umul128 with:
    • return _Base128::_UMul128(__a, __b, *__productHi);
  • Keep ARM64 intrinsic path unchanged for native behavior there.

Rationale

After #6281, _Base128::_UMul128() is available as a common, well-tested fallback path. Reusing it from __ryu_umul128:

  • avoids duplicated/parallel implementations,
  • reduces maintenance overhead,
  • preserves behavior parity across xcharconv and other internal integer helpers.

Validation

  • Confirmed header-level change compiles conceptually with existing internal use.
  • Diff is limited to:
    • stl/inc/xcharconv_ryu.h
    • behavior remains unchanged for intrinsic paths.
Copilot AI review requested due to automatic review settings July 9, 2026 15:24
@notedavidrinaldi
DAVID RINALDI (notedavidrinaldi) requested a review from a team as a code owner July 9, 2026 15:24
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Jul 9, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
@notedavidrinaldi

Copy link
Copy Markdown
Author

Hi team — I understand this PR is blocked by code-owner review.

Could we please get a review from the microsoft/vclibs code owners for:
#6355

Thanks! This PR addresses #6352 and only changes:

  • stl/inc/xcharconv_ryu.h
    • unify __ryu_umul128 fallback path with shared __msvc_int128.hpp::_Base128::_UMul128.

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 removes the duplicated 128-bit multiply fallback in <xcharconv_ryu.h> by delegating to the shared, well-tested _Base128::_UMul128() in <__msvc_int128.hpp>. This addresses issue #6352, following #6281 which unified the ARM64/x64 intrinsic paths, so the two helpers no longer maintain parallel x86/constexpr fallback implementations.

Changes:

  • Include <__msvc_int128.hpp> so __ryu_umul128 can call _Base128::_UMul128.
  • Replace the native-X64 intrinsic fallback and the entire non-intrinsic manual multiply in __ryu_umul128 with a call to _Base128::_UMul128(__a, __b, *__productHi).
  • Keep the ARM64/ARM64EC __umulh intrinsic path unchanged.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread stl/inc/xcharconv_ryu.h Outdated
#include <xcharconv.h>
#include <xcharconv_ryu_tables.h>
#include <xutility>
#include <__msvc_int128.hpp>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the review! Fixed in latest push:

  • moved #include <__msvc_int128.hpp> to the top of the include block before standard headers, matching STL internal include-order conventions.

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@notedavidrinaldi

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 6355 in repo microsoft/STL
@notedavidrinaldi

Copy link
Copy Markdown
Author

I can't trigger pipeline because no privileges; please run /azp run on this PR.

@StephanTLavavej

Copy link
Copy Markdown
Member

We haven't merged #6281 yet, and there's no benchmark results here demonstrating that you've picked the faster implementation.

@StephanTLavavej

Copy link
Copy Markdown
Member

I've benchmarked this on x86 and we need to do the opposite. Closing this PR, I'll create one myself (Ryu has special licensing that needs to be dealt with). Thanks for looking into this.

For future reference, please note how our PR template mentions that AI-generated pull requests and AI-generated PR descriptions are discouraged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster

4 participants