3 Commits

Author SHA1 Message Date
Yingwei Zheng
cf5cd98e74
[InstCombine] Support and/or in getFreelyInvertedImpl using DeMorgan's Law (#85193)
This patch adds the support for and/or in `getFreelyInvertedImpl` using
DeMorgan's Law:
```
(~(A | B)) -> (~A & ~B)
(~(A & B)) -> (~A | ~B)
```
Alive2: https://alive2.llvm.org/ce/z/Uig8-j
2024-03-15 19:10:02 +08:00
hanbeom
6cdf596c52
[InstCombine] If inst in unreachable refers to an inst change it to poison (#78444)
Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of a return instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.

Fixes #65107.
2024-03-06 09:42:33 +01:00
Nikita Popov
bc49103015 [InstCombine] Don't handle constants in de morgan folds (PR63791)
If the and/or operand is an immediate constant, it will get folded
away anyway. Don't try to freely invert those operands.

A particularly degenerate case of this arises when both operands
are constant and the result is a constant, in which case we try
to invert users of a constant, resulting in an assertion failure.

Fixes https://github.com/llvm/llvm-project/issues/63791.
2023-07-11 15:18:53 +02:00