summaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2024-04-15 16:40:16 +0800
committerGitHub <noreply@github.com>2024-04-15 16:40:16 +0800
commit5fe146672d2b1c9f257a6ee045e0bc13fed1e504 (patch)
tree48348ee092235a8a12befe137c72dd4bcf66cdd2 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent06714e1bfe8999c0acb5c9b94b60690f7b9d2904 (diff)
[InstCombine] Simplify switch with selects (#84143)
An example from https://github.com/image-rs/image: ``` define void @test_ult_rhsc(i8 %x) { %val = add nsw i8 %x, -2 %cmp = icmp ult i8 %val, 11 %cond = select i1 %cmp, i8 %val, i8 6 switch i8 %cond, label %bb1 [ i8 0, label %bb2 i8 10, label %bb3 ] bb1: call void @func1() unreachable bb2: call void @func2() unreachable bb3: call void @func3() unreachable } ``` When `%cmp` evaluates to false, we can prove that the range of `%val` is [11, umax]. Thus we can safely replace `%cond` with `%val` since both `switch 6` and `switch %val` go to the default dest `%bb1`. Alive2: https://alive2.llvm.org/ce/z/uSTj6w Godbolt: https://godbolt.org/z/MGrG84bzr This patch will benefit many rust applications and some C/C++ applications (e.g., cvc5).
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions