aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Serialization/InMemoryModuleCacheTest.cpp
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2024-11-21 15:33:18 +0800
committerGitHub <noreply@github.com>2024-11-21 15:33:18 +0800
commita6fefc82450e054336a52a5d2d915b780b8c3ef7 (patch)
tree67e166710376ae0f6b48c3fe9419885fbf079561 /clang/unittests/Serialization/InMemoryModuleCacheTest.cpp
parent7c0786363e6b14e05a868cfe7614074cf742e7cc (diff)
downloadllvm-a6fefc82450e054336a52a5d2d915b780b8c3ef7.zip
llvm-a6fefc82450e054336a52a5d2d915b780b8c3ef7.tar.gz
llvm-a6fefc82450e054336a52a5d2d915b780b8c3ef7.tar.bz2
[InstCombine] Convert logical and/or with `icmp samesign` into bitwise ops (#116983)
See the following case: ``` define i1 @test_logical_and_icmp_samesign(i8 %x) { %cmp1 = icmp ne i8 %x, 9 %cmp2 = icmp samesign ult i8 %x, 11 %and = select i1 %cmp1, i1 %cmp2, i1 false ret i1 %and } ``` Currently we cannot convert this logical and into a bitwise and due to the `samesign` flag. But if `%cmp2` evaluates to `poison`, we can infer that `%cmp1` is either `poison` or `true` (`samesign` violation indicates that X is negative). Therefore, `%and` still evaluates to `poison`. This patch converts a logical and into a bitwise and iff TV is poison implies that Cond is either poison or true. Likewise, we convert a logical or into a bitwise or iff FV is poison implies that Cond is either poison or false. Note: 1. This logic is implemented in InstCombine. Not sure whether it is profitable to move it into ValueTracking and call `impliesPoison(TV/FV, Sel)` instead. 2. We only handle the case that `ValAssumedPoison` is `icmp samesign pred X, C1` and `V` is `icmp pred X, C2`. There are no suitable variants for `isImpliedCondition` to pass the fact that X is [non-]negative. Alive2: https://alive2.llvm.org/ce/z/eorFfa Motivation: fix [a major regression](https://github.com/dtcxzyw/llvm-opt-benchmark/pull/1724#discussion_r1849663863) to unblock https://github.com/llvm/llvm-project/pull/112742.
Diffstat (limited to 'clang/unittests/Serialization/InMemoryModuleCacheTest.cpp')
0 files changed, 0 insertions, 0 deletions