diff options
author | Yingwei Zheng <dtcxzyw2333@gmail.com> | 2024-04-29 15:51:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-29 15:51:49 +0800 |
commit | ab12bba0aad800c1805eca2ea937da958c1854c8 (patch) | |
tree | 6a02bc5678ac4a7e017f02353bc43aa13845b458 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 41942c852e2be6c7c37f41e5128d446182fc9763 (diff) | |
download | llvm-ab12bba0aad800c1805eca2ea937da958c1854c8.zip llvm-ab12bba0aad800c1805eca2ea937da958c1854c8.tar.gz llvm-ab12bba0aad800c1805eca2ea937da958c1854c8.tar.bz2 |
[CGP] Drop poison-generating flags after hoisting (#90382)
See the following case:
```
define i8 @src1(i8 %x) {
entry:
%cmp = icmp eq i8 %x, -1
br i1 %cmp, label %exit, label %if.then
if.then:
%inc = add nuw nsw i8 %x, 1
br label %exit
exit:
%retval = phi i8 [ %inc, %if.then ], [ -1, %entry ]
ret i8 %retval
}
define i8 @tgt1(i8 %x) {
entry:
%inc = add nuw nsw i8 %x, 1
%0 = icmp eq i8 %inc, 0
br i1 %0, label %exit, label %if.then
if.then: ; preds = %entry
br label %exit
exit: ; preds = %if.then, %entry
%retval = phi i8 [ %inc, %if.then ], [ -1, %entry ]
ret i8 %retval
}
```
`optimizeBranch` converts `icmp eq X, -1` into cmp to zero on RISC-V and
hoists the add into the entry block. Poison-generating flags should be
dropped as they don't still hold.
Proof: https://alive2.llvm.org/ce/z/sP7mvK
Fixes https://github.com/llvm/llvm-project/issues/90380
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
0 files changed, 0 insertions, 0 deletions