diff options
author | Heejin Ahn <aheejin@gmail.com> | 2022-06-10 21:51:16 -0700 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2022-06-13 18:32:09 -0700 |
commit | ac4006b0d69ff3349fdd6c0bf8e4dad9504d438a (patch) | |
tree | 46409c1a596c2a85da5e6fb83c870b32667e9bbf /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | 3b6e166999bb83197c8b70468c2d371c58cf0c25 (diff) | |
download | llvm-ac4006b0d69ff3349fdd6c0bf8e4dad9504d438a.zip llvm-ac4006b0d69ff3349fdd6c0bf8e4dad9504d438a.tar.gz llvm-ac4006b0d69ff3349fdd6c0bf8e4dad9504d438a.tar.bz2 |
[InstCombine] Don't slice up PHIs when pred BB has catchswitch
If an integer PHI has an illegal type (according to the data layout) and
it is only used by `trunc` or `trunc(lshr)` operations, we split the PHI
into various instructions in its predecessors:
https://github.com/llvm/llvm-project/blob/6d1543a16797fa07eecea7e542df5b42422fc721/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp#L1536-L1543
So this can produce code like the following:
Before:
```
pred:
...
bb:
%p = phi i8 [ %somevalue, %pred ], ...
...
%tobool = trunc i8 %p to i1
use %tobool
...
```
In this code, `%p` has an illegal integer type, `i8`, and its only used
in a `trunc` instruction later. In this case this pass puts extraction
code in its predecessors:
After:
```
pred:
...
%t = and i8 %somevalue, 1
%extract = icmp ne i8 %t, 0
bb:
%p.new = phi i1 [ %extract, %pred ], ...
use %p.new instead of %tobool
```
But this doesn't work if `pred` is a `catchswitch` BB because it cannot
have any non-PHI instructions. This CL ensures we bail out in that case.
Fixes https://github.com/llvm/llvm-project/issues/55803.
Reviewed By: dschuff
Differential Revision: https://reviews.llvm.org/D127699
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
0 files changed, 0 insertions, 0 deletions