| Issue |
76609
|
| Summary |
[JumpThreading] Missing optimization: thread over a nearly empty basicblock
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
XChy
|
Alive2 proof: https://alive2.llvm.org/ce/z/Lv9e4r
### Description:
```llvm
define i1 @src(i1 %c1) {
entry:
%c = call i1 @cond()
br i1 %c, label %then, label %else
then:
call void @dummy()
br i1 %c1, label %else, label %return
else:
br label %return
return:
%retval.0 = phi i1 [ true, %else ], [ false, %then ]
ret i1 %retval.0
}
```
can be folded to:
```llvm
define i1 @tgt(i1 %c1) {
entry:
%c = call i1 @cond()
br i1 %c, label %then, label %return
then:
call void @dummy()
br i1 %c1, label %else, label %return
else:
br label %return
return:
%retval.0 = phi i1 [ true, %entry ], [ false, %then ], [true, %else]
ret i1 %retval.0
}
```
The conditional branch in BB `entry` can thread directly through nearly empty BB `else` to `return`.
### Real-world motivation
This snippet of IR is derived from auto-generated [qemu/xxx/qapi-visit-dump.c](https://github.com/qemu/qemu/blob/master/qapi/dump.json) (after O3 pipeline).
The example above is a reduced version. If you're interested in the original suboptimal IR and optimal IR, see also:
**Let me know if you can confirm that it's an optimization opportunity, thanks.**
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs