llvm / llvm/llvm-project

Missed optimization: (x + smin(y, 0)) + smax(y, 0) -> x + y

Open
#187,057 6 comments 0 reactions 1 assignee Claimed by @MitchBriles View on GitHub
llvm:transforms missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```llvm
define i64 @src(i64 %x, i64 %y) {
%a = call i64 @llvm.smax.i64(i64 %y, i64 0)
%b = call i64 @llvm.smin.i64(i64 %y, i64 0)
%s = add i64 %x, %b
%r = add i64 %s, %a
ret i64 %r
}

define i64 @tgt(i64 %x, i64 %y) {
%r = add i64 %x, %y
ret i64 %r
}
```

https://alive2.llvm.org/ce/z/qkZnzM
https://godbolt.org/z/3h3KrfoWq

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.