llvm / llvm/llvm-project

Missed Optimization: Fold x - umin(x,13) < 2 into single compare x < 15

Open
#167,055 2 comments 0 reactions 1 assignee Claimed by @ParkHanbum View on GitHub
llvm:instcombine missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```
define i1 @src(i64 %arg0) {
%v0 = tail call i64 @llvm.umin.i64(i64 %arg0, i64 13)
%v1 = sub nsw i64 %arg0, %v0
%v2 = icmp slt i64 %v1, 2
ret i1 %v2
}

define i1 @tgt(i64 %arg0) {
%v0 = icmp slt i64 %arg0, 15
ret i1 %v0
}
```
alive2: https://alive2.llvm.org/ce/z/pyUQAP
godbolt: https://godbolt.org/z/TaYWM9GTe
Pattern found in: https://github.com/dtcxzyw/llvm-opt-benchmark/blob/main/bench/ffmpeg/optimized/pictordec.ll

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.