[llvm] [InstCombine] Fix miscompilation in sinkNotIntoOtherHandOfLogicalOp (PR #226783)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 27 06:22:32 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Andreas Jonson (andjo403)

<details>
<summary>Changes</summary>

Consider the following: `or X, (not (not X))` sinkNotIntoOtherHandOfLogicalOp calls `freelyInvert(X)` but as X is used in the not this call result in the new instruction is `and (not X), (not (not X)) -> and (not X), X` instead of the expected `and (not X), (not X)`

fixes https://github.com/llvm/llvm-project/issues/226504

---
Full diff: https://github.com/llvm/llvm-project/pull/226783.diff


3 Files Affected:

- (modified) llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (+6) 
- (added) llvm/test/Transforms/InstCombine/pr226504-commuted.ll (+20) 
- (added) llvm/test/Transforms/InstCombine/pr226504.ll (+20) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````

</details>


https://github.com/llvm/llvm-project/pull/226783


More information about the llvm-commits mailing list