diff options
| author | chenglin.bi <chenglin.bi@linaro.org> | 2023-03-02 20:45:54 +0800 |
|---|---|---|
| committer | chenglin.bi <chenglin.bi@linaro.org> | 2023-03-02 20:46:16 +0800 |
| commit | 97dcbea63e11d566cff0cd3a758cf1114cf1f633 (patch) | |
| tree | 848d661b9f1cc520b73b48f45da33e295deae821 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
| parent | 28eef3bd5bc7cf2544df6fd8ab83c67e500b126c (diff) | |
| download | llvm-97dcbea63e11d566cff0cd3a758cf1114cf1f633.zip llvm-97dcbea63e11d566cff0cd3a758cf1114cf1f633.tar.gz llvm-97dcbea63e11d566cff0cd3a758cf1114cf1f633.tar.bz2 | |
[LogicCombine 1/?] Implement a general way to simplify logical operations.
This patch involves boolean ring to simplify logical operations. We can treat `&` as ring multiplication and `^` as ring addition.
So we need to canonicalize all other operations to `*` `+`. Like:
```
a & b -> a * b
a ^ b -> a + b
~a -> a + 1
a | b -> a * b + a + b
c ? a : b -> c * a + (c + 1) * b
```
In the code, we use a mask set to represent an expression. Every value that is not comes from logical operations could be a bit in the mask.
The mask itself is a multiplication chain. The mask set is an addiction chain.
We can calculate two expressions based on boolean algebras.
For now, the initial patch only enabled on and/or/xor, Later we can enhance the code step by step.
Reference: https://en.wikipedia.org/wiki/Boolean_ring
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D142803
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
0 files changed, 0 insertions, 0 deletions
