[llvm] [SimplifyCFG] Simplify uncond br with icmp & select (PR #165580)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 8 03:50:31 PST 2025


================
@@ -5011,25 +5013,101 @@ bool SimplifyCFGOpt::simplifyIndirectBrOnSelect(IndirectBrInst *IBI,
 /// the PHI, merging the third icmp into the switch.
 bool SimplifyCFGOpt::tryToSimplifyUncondBranchWithICmpInIt(
     ICmpInst *ICI, IRBuilder<> &Builder) {
+  // Select == nullptr means we assume that there is a hidden no-op select
+  // instruction of _ = `select %icmp, true, false` just after `%icmp = ...`
+  return tryToSimplifyUncondBranchWithICmpSelectInIt(ICI, nullptr, Builder);
+}
+
+/// Similar to tryToSimplifyUncondBranchWithICmpInIt, but handle a more generic
+/// case. This is called when we find an icmp instruction (a seteq/setne with a
+/// constant) and its following select instruction as the only TWO instruction
----------------
dtcxzyw wrote:

```suggestion
/// constant) and its following select instruction as the only TWO instructions
```

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


More information about the llvm-commits mailing list