llvm / llvm/llvm-project

[InstCombine] Incorrect addition of `nsz` to `llvm.minnum`: target's return value is more undefined

Open
#189,732 2 comments 0 reactions 0 assignees View on GitHub
llvm:instcombine miscompilation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Hi, I found a miscompilation in InstCombine.
Alive2 reports that the target's return value is more undefined than the source.

```llvm
define nofpclass(nsub) float @src(float %unknown, float noundef nofpclass(pinf zero sub norm) %must.be.ninf.or.nan) {
%result = call float @llvm.minnum.f32(float %must.be.ninf.or.nan, float %unknown)
ret float %result
}
```
```llvm
define nofpclass(nsub) float @tgt(float %unknown, float noundef nofpclass(pinf zero sub norm) %must.be.ninf.or.nan) {
%result = call nsz float @llvm.minnum.f32(float %must.be.ninf.or.nan, float %unknown)
ret float %result
}
```

Alive2 report:
https://alive2.llvm.org/ce/z/ji6x4X
LLVM opt:
https://godbolt.org/z/3d3bqKqvT

This is introduced by PR #179299.

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.