Skip to content

Fix #3891: Add LLVM 22.1 patch for select into masked load miscompile - #3932

Merged
aneshlya merged 1 commit into
ispc:mainfrom
aneshlya:3891-fix
Oct 8, 2026
Merged

aneshlya merged 1 commit into
ispc:mainfrom
aneshlya:3891-fix

Conversation

@aneshlya

@aneshlya aneshlya commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

InstCombine folded select(mask, masked.load(ptr, mask, PT), FV) into a new masked load created at the select, sinking it below an aliasing store. On AVX-512 this broke swaps like tmp = a[i]; a[i] = cur; cur = tmp.

Backport upstream fec2cbad1539 (llvm/llvm-project#216730) to LLVM 22.1 and add a lit regression test.

Related Issue

  • Linked to relevant issue(s)

Checklist

  • Code has been formatted with clang-format (e.g., clang-format -i src/ispc.cpp)
  • Git history has been squashed to meaningful commits (one commit per logical change)
  • Compiler changes are covered by lit tests
  • Language/stdlib changes include new functional tests for runtime behavior
  • Documentation updated if needed

…pile

InstCombine folded select(mask, masked.load(ptr, mask, PT), FV) into a
new masked load created at the select, sinking it below an aliasing
store. On AVX-512 this broke swaps like tmp = a[i]; a[i] = cur; cur = tmp.

Backport upstream fec2cbad1539 (llvm/llvm-project#216730) to LLVM 22.1
and add a lit regression test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@aneshlya aneshlya linked an issue Oct 8, 2026 that may be closed by this pull request
@aneshlya
aneshlya requested review from azwolski and dbabokin October 8, 2026 18:34

@dbabokin dbabokin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@aneshlya
aneshlya merged commit efe3124 into ispc:main Oct 8, 2026
159 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ISPC 1.31 AVX-512 miscompile: masked load sunk below masked store

2 participants