Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STL: Mark simple casting free functions with _MSVC_INTRINSIC #3548

Closed
frederick-vs-ja opened this issue Mar 7, 2023 · 2 comments · Fixed by #3664
Closed

STL: Mark simple casting free functions with _MSVC_INTRINSIC #3548

frederick-vs-ja opened this issue Mar 7, 2023 · 2 comments · Fixed by #3664
Labels
fixed Something works now, yay! performance Must go faster

Comments

@frederick-vs-ja
Copy link
Contributor

frederick-vs-ja commented Mar 7, 2023

#3182 added [[msvc::intrinsic]] attribute to the following reference-casting function templates:

  • forward
  • forward_like
  • move
  • move_if_noexcept

, which made MSVC treat a call to such a function equivalent to a simple static_cast.

Per local verifications and response from @cdacamar on Discord, it works for free functions which is equivalent to a cast. Here is an incomplete list of such functions, including internal helpers, in MSVC STL:

  • Reference casting functions (I've verified locally some of them and believe [[msvc::intrinsic]] works)
    • as_const (in <utility>)
    • _Possibly_const_range (in <xutility>)
    • _As_lvalue (in <ranges>)
  • Pointer casting functions (seemly works, but not very sure)
    • _As_const_pointer (in <xutility>)
  • Integer/enumeration casting functions (seemly works, but not very sure)
    • to_integer (in <cstddef>)
    • to_underlying (in <utility>)

It would be great to find all of these functions and mark them with _MSVC_INTRINSIC.

Note that the [[msvc::intrinsic]] attribute currently doesn't work for member functions (both non-static and static ones), so even though identity::operator() looks like a good candidate, it's better not to mark it with _MSVC_INTRINSIC at this moment.

@JMazurkiewicz suggested that this might be a nice candidate for "good first issue".

@StephanTLavavej StephanTLavavej added the performance Must go faster label Mar 8, 2023
@StephanTLavavej
Copy link
Member

The actual changes will be good-first-issue material, but the need to do a global audit is beyond what we typically consider such an issue.

@frederick-vs-ja
Copy link
Contributor Author

frederick-vs-ja commented Jul 14, 2023

_As_lvalue is somehow problematic and not yet suitable for [[msvc::intrinsic]] in 17.7 Preview 3.

@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Something works now, yay! performance Must go faster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants