[llvm] [JumpThreading] Thread over BB with only an unconditional branch (PR #86312)

Quentin Dian via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 23 17:35:51 PDT 2024


DianQK wrote:

Hmm, please consider the following case: 

```llvm
define i32 @thread_uncond_bb_cmp_zext(i1 %c, i32 %v, i32 %v2, i32 %v3) {
entry:
  br i1 %c, label %do.end, label %if.then

if.then:                                          ; preds = %entry
  call void @dummy()
  %tobool = icmp eq i32 %v, 0
  br i1 %tobool, label %do.end, label %return

do.end:                                           ; preds = %entry, %if.then
  br label %return

return:                                           ; preds = %if.then, %do.end
  %retval = phi i32 [ %v2, %do.end ], [ %v3, %if.then ]
  ret i32 %retval
}

declare void @dummy()
```

https://llvm.godbolt.org/z/74f7qz54E.

The generated code will become more complex if other passes cannot eliminate a branch instruction or convert it into a select instruction.

https://github.com/llvm/llvm-project/pull/86312


More information about the llvm-commits mailing list