| Issue |
238952
|
| Summary |
[InstCombine] Missed unsigned division elimination for a zero-extended divisor
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Leo0506
|
InstCombine misses an opportunity to eliminate unsigned division using known divisor range information.
```llvm
define i1 @src(i64 %a, i32 %y) {
%b = zext i32 %y to i64
%d = udiv i64 %a, %b
%c = icmp ugt i64 %d, 1
ret i1 %c
}
```
Can be rewritten as:
```llvm
define i1 @tgt(i64 %a, i32 %y) {
%b = zext i32 %y to i64
%t = shl i64 %b, 1
%c = icmp uge i64 %a, %t
ret i1 %c
}
```
Alive2 proof: https://alive2.llvm.org/ce/z/vdnMOu
On x86-64 (cascadelake), eliminating the 64-bit division gives:
| Metric | Source | Target |
|---|---:|---:|
| Instructions | 15 | 5 |
| μOps (100 iterations) | 8,100 | 700 |
| llvm-mca cycles | 5,310 | 161 |
| Reciprocal throughput | 16.0 | 1.2 |
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs