Skip to content

Fix missing bytesize check for safe find vectorization with LLVM - #6298

Merged
Stephan T. Lavavej (StephanTLavavej) merged 12 commits into
microsoft:mainfrom
mgovers:GH006294-llvm-vectorization-is-safe
Oct 18, 2026
Merged

Stephan T. Lavavej (StephanTLavavej) merged 12 commits into
microsoft:mainfrom
mgovers:GH006294-llvm-vectorization-is-safe

Conversation

@mgovers

Copy link
Copy Markdown
Contributor

Fixes #6294

Here's my attempt at excluding odd-sized and large-sized structs from the vectorization in xutility.

Design approach

I have tried to follow all the conventions used elsewhere as much as possible, in particular:

  • for the implementation, I followed what was already there and the changes from Vectorize find-like algorithms for Clang for more types #5767
  • for the tests, following 3da7d27
    • NOTE: I explicitly scoped out equivalent tests as for _Equal_memcmp_is_safe as the current main implementation of _Vector_alg_in_find_is_safe was not tested in the first place. I still opted to add a couple more tests than for _Vector_alg_in_search_is_safe to at the very least show that there's vectorization for MSVC and not only for Clang
  • Since _Vector_alg_in_search_is_safe already had a similar check as what was needed here, I re-used that one (had to move it outside the #ifdef statement, though)
    • I did multiple searches for strings like _VECTORIZED_FIND, static_assert(false, "unexpected size");, _vectorized( and _Nx <= 8 && (_Nx & (_Nx - 1)) == 0 to see if there were other cases that I missed. I believe (and hope) I got them all (at least in algorithm and xutility).
    • I intentionally did not include MINMAX-like things, because they are independently explicitly guarded where the vectorized versions are used.

Additional remarks/open questions

  • I am re-running all tests locally once more as we speak, but it seems like some unrelated tests are failing on my device, also on main, so those are not an issue with my branch.
    • I will compare the failed scenarios once I'm finished running.
    • I am already opening this PR in the hope that CI will tell me for sure.
  • What is the best way (if any) to add the test case from <xutility>: std::find no longer compiles with structs with defaulted equality comparison with Clang-CL #6294 ?
    • Is it worth the effort to create a very small test file that contains exactly that edge case?
    • Or should I add it to the one I already added?
  • Should I benchmark? Or will that be done on your end?
    • (cfr. For performance-sensitive code (e.g. containers and algorithms) you may wish to write and/or run benchmarks, and the STL team will likely run any benchmarks we do have in our PR process.)
    • It is touching sensitive code (very common algorithms with high performance demands) and explicitly disabling vectorization (which is, in fact, a bugfix and it should only be excluding things that never compiled in the first place, but still...)

Despite my questions, I think (and hope) that my contribution is in a good state anyways.

Copilot AI review requested due to automatic review settings May 27, 2026 06:44
@mgovers
Martijn Govers (mgovers) requested a review from a team as a code owner May 27, 2026 06:44
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews May 27, 2026

This comment was marked as resolved.

Signed-off-by: Martijn Govers <[email protected]>
@StephanTLavavej

This comment was marked as resolved.

@azure-pipelines

This comment was marked as resolved.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the bug Something isn't working label May 27, 2026
@mgovers

This comment was marked as resolved.

@AlexGuteniev

This comment was marked as resolved.

@mgovers

This comment was marked as resolved.

@AlexGuteniev

This comment was marked as resolved.

@mgovers

This comment was marked as resolved.

@AlexGuteniev

This comment was marked as resolved.

@StephanTLavavej

This comment was marked as resolved.

@mgovers Martijn Govers (mgovers) changed the title Fix #6294 missing bytesize check for safe find vectorization with LLVM Fix missing bytesize check for safe find vectorization with LLVM May 28, 2026
@mgovers

This comment was marked as resolved.

@mgovers

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Alliander"

Copilot AI review requested due to automatic review settings July 29, 2026 08:59

This comment was marked as resolved.

@StephanTLavavej

This comment was marked as resolved.

@azure-pipelines

This comment was marked as resolved.

@StephanTLavavej

This comment was marked as resolved.

@mgovers

This comment was marked as resolved.

Jonas Heinle (Kataglyphis) added a commit to Kataglyphis/ANTfrastructure that referenced this pull request Sep 26, 2026
…the owner's

Every open BACKLOG.md item was worked on 2026-09-26. Image fixes ship with the
next publish (CON11 :latest, CON12 :winamd64); each was proven against the
published image in a throwaway container or a buildkit probe. Both chains
rebuild from base at that publish anyway (versions.env changed since each
published image), so none of this adds a re-key.

Hub scripts, effective now:
- CON33: Copy-MediaRuntimeBundle probes GSTREAMER_BIN, the image's
  C:\runtime\bin; AccelerANTgine run 36044940426 had staged only ORT.
- CON32: the Rust driver checks for cargo fmt/clippy instead of running
  rustup component add.

Linux image (ships with CON11):
- CON14: the android-sdk-shared cache id never named the two API 37 pins, so
  every build after 2bb0410 restored a 2026-08-22 SDK tree. The id names every
  pin (tests/test-android-sdk-cache-key.sh); a restored tree is checked against
  sdkmanager's package.xml records, completed and refreshed; the smoke checks
  every platform.
- CON15/CON16/CON17: clang's own LLVM tools on PATH (clang-format and
  llvm-config stay 21 on purpose); <native-triple>-clang{,++}.cfg select
  ${GCC_PREFIX}; compiler-rt builds libFuzzer. validate-compilers.sh smoke
  checks all three. The package stage's new functions live in
  06-packaging/package-image-wiring.sh (setup-package-image.sh hit 800 lines).
- CON18: VIRTUAL_ENV/UV_PYTHON emptied in Dockerfile.torch, unset by the
  entrypoint.
- CON19/CON20: lavapipe, perf (linux-perf), gperftools, jq, Xvfb.
- CON21: amd64 drops the unused distro GTK 4 + GStreamer 1.28 runtime.
- CON23: libcamera-env.sh lets a caller's paths win; the entrypoint keeps
  GCC 16.2's runtime ahead of a caller's LD_LIBRARY_PATH.
- CON36 (found on the way): build-gcc.sh ran only ${TARGET_TRIPLET}-strip,
  which cannot read a plain cross compiler's x86-64 executables; with the
  build machine's strip too, /opt/gcc-16.2.0 goes from 4.9 to 1.4 GB.

Windows image (ships with CON12):
- CON9/CON10: the patched LLVM builds clang_rt.profile (profile_rocm off) and
  clang-tools-extra; libFuzzer's switch is spelled right; the stage fails
  without them, and its 7.1 GB source tree no longer stays in the layer. Proven
  by rebuilding the tree shipped in :winamd64: coverage runs to llvm-cov for
  /MDd, /MD+ASan and cmake/Tests.cmake, and the new clang-tidy reads a
  clang-cl BMI that scoop's refuses.
- CON25: the final stage puts LunarG's vulkan-1.dll on PATH (never System32);
  a Vulkan-linked program went from 0xC0000135 to running, gstvulkan loads.
  OpenGL stays host-only (owner decision: no unsigned Mesa builds).
- CON28: the app venv installs ai-edge-litert from the lock (the app smoke
  passes it); CON29: no baked WORKDIR/VOLUME C:\workspace.

Decided (BACKLOG § Deliberate): CON20's cargo-audit/cargo-deny and Linux
pwsh, CON21 on arm64/riscv64, CON22, CON24 (flags in
riscv64-rva23-baseline.md), five Windows absences (CON28), and OpenGL in the
Windows image (CON25). CON27 waits on microsoft/STL#6298. Filed: CON35,
amd64's TVM cannot load its compiler.

Gates: preflight green locally. The pre-commit mutation stage cannot grade
five web-lane/package entries on this Windows host: Git Bash's symlinks break
test-setup-package-image.sh's JAVA_HOME fixture (it fails on clean HEAD too)
and test-web-lane-tools.sh exceeds 300 s. In the Linux image all five bite
and both suites pass (95/95).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread stl/inc/xutility Resolved
Comment thread stl/inc/xutility Resolved
Copilot AI balanced review requested due to automatic review settings October 16, 2026 17:19
@StephanTLavavej

This comment was marked as resolved.

@azure-pipelines

This comment was marked as resolved.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Initial Review to Ready To Merge in STL Code Reviews Oct 16, 2026

This comment was marked as resolved.

@StephanTLavavej

This comment was marked as resolved.

Copilot AI balanced review requested due to automatic review settings October 16, 2026 17:34
@StephanTLavavej

This comment was marked as resolved.

@azure-pipelines

This comment was marked as resolved.

This comment was marked as resolved.

@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo. Please notify me if any further changes are pushed, otherwise no action is required.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Ready To Merge to Merging in STL Code Reviews Oct 16, 2026
@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 6549709 into microsoft:main Oct 18, 2026
48 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Oct 18, 2026
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for fixing this bug and congrats on your first microsoft/STL commit! 😻

This fix will be available in the MSVC Build Tools 14.53. Apologies for taking so long to review this that it missed the 14.52 release.

@mgovers

Copy link
Copy Markdown
Contributor Author

Thanks for fixing this bug and congrats on your first microsoft/STL commit! 😻

This fix will be available in the MSVC Build Tools 14.53. Apologies for taking so long to review this that it missed the 14.52 release.

Awesome! Thanks for all the help and no worries, I fully understand! Just happy to be able to a part of this!

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

Labels

bug Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

<xutility>: std::find no longer compiles with structs with defaulted equality comparison with Clang-CL

4 participants