[llvm] [Support][KnownFPClass] Refine fdiv and fdiv_self class propagation + some minor fixes for propagateXorSign (PR #215014)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 8 14:46:06 PDT 2026


dtcxzyw wrote:

The following correctness issue was found by [llvm-hackme](https://github.com/dtcxzyw/llvm-hackme).

<!-- llvm-hackme-state: bug_found -->
<!-- llvm-hackme-baseline: 1e11d911354830a63c32eb986acbce56065bed7c -->
<!-- llvm-hackme-head-sha: 1a78ed7246c548041d9787762e5e4abd642c0057 -->
<!-- llvm-hackme-patch-sha256: e98b41a09427bfe585aea72c54cfac76c9e810cea1f6303902d81197354e07ef -->
<!-- llvm-hackme-kind: miscompilation -->

This comment is generated by an automated correctness checking service designed to help identify critical correctness bugs (opt crashes or Alive2 miscompilations) and improve PR review efficiency under limited reviewer bandwidth.

The reproducer was generated by LLM.

This bug is a regression introduced by this PR. It does not reproduce on the baseline commit.

## Reproducer

**Kind**: miscompilation

**IR Reproducer**:
```llvm
; RUN: opt -passes=instcombine<no-verify-fixpoint> -S
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i1 @f(half nofpclass(ninf nnorm nzero) %x, half nofpclass(pinf pzero psub pnorm nsub) %y) #0 {
  %d = fdiv half %x, %y
  %r = call i1 @llvm.is.fpclass.f16(half %d, i32 96)
  ret i1 %r
}


attributes #0 = { denormal_fpenv(positivezero|positivezero) }
```

**Alive2 Counterexample**:
```
----------------------------------------
define i1 @f(half nofpclass(44) %x, half nofpclass(976) %y) denormal-fp-math=positive-zero,positive-zero {
#0:
  %d = fdiv half nofpclass(44) %x, nofpclass(976) %y
  %r = is.fpclass half %d, i32 96
  ret i1 %r
}
=>
define i1 @f(half nofpclass(44) %x, half nofpclass(976) %y) denormal-fp-math=positive-zero,positive-zero {
#0:
  %d = fdiv half nofpclass(44) %x, nofpclass(976) %y
  %r = is.fpclass half %d, i32 32
  ret i1 %r
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
half nofpclass(44) %x = #x8005 (-0.000000298023?)
half nofpclass(976) %y = #xf400 (-16384)

Source:
half %d = #x0000 (+0.0)
i1 %r = #x1 (1)

Target:
half %d = #x0000 (+0.0)
i1 %r = #x0 (0)
Source value: #x1 (1)
Target value: #x0 (0)

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```

**Opt Output**:
```llvm
; ModuleID = '/tmp/tmpuq55n1iq.ll'
source_filename = "/tmp/tmpuq55n1iq.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: denormal_fpenv(positivezero)
define i1 @f(half nofpclass(ninf nzero nnorm) %x, half nofpclass(pinf pzero sub pnorm) %y) #0 {
  %d = fdiv half %x, %y
  %r = call i1 @llvm.is.fpclass.f16(half %d, /* (nzero) */ i32 32)
  ret i1 %r
}

; Function Attrs: nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f16(half, i32 immarg) #1

attributes #0 = { denormal_fpenv(positivezero) }
attributes #1 = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }
```


**Baseline Revision**: `1e11d911354830a63c32eb986acbce56065bed7c`
**PR Head SHA**: `1a78ed7246c548041d9787762e5e4abd642c0057`
**Patch SHA256**: `e98b41a09427bfe585aea72c54cfac76c9e810cea1f6303902d81197354e07ef`


https://github.com/llvm/llvm-project/pull/215014


More information about the llvm-commits mailing list