| Issue |
162111
|
| Summary |
[SimplifyCFG] switch on umin can be converted to use default dest
|
| Labels |
llvm:optimizations,
missed-optimization
|
| Assignees |
|
| Reporter |
nikic
|
https://alive2.llvm.org/ce/z/_N6nfs
```llvm
define void @src(i32 %x) {
%min = call i32 @llvm.umin.i32(i32 %x, i32 3)
switch i32 %min, label %unreachable [
i32 0, label %case0
i32 1, label %case1
i32 2, label %case2
i32 3, label %case3
]
case0:
call void @a()
ret void
case1:
call void @b()
ret void
case2:
call void @c()
ret void
case3:
ret void
unreachable:
unreachable
}
define void @tgt(i32 %x) {
switch i32 %x, label %case3 [
i32 0, label %case0
i32 1, label %case1
i32 2, label %case2
]
case0:
call void @a()
ret void
case1:
call void @b()
ret void
case2:
call void @c()
ret void
case3:
ret void
unreachable:
unreachable
}
declare void @a()
declare void @b()
declare void @c()
```
The umin here maps "all the remaining cases" to 3 and then has an explicit case for 3. We could use the switch default instead.
(This inverse of this does seem like a reasonable backend lowering strategy though.)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs