Issue 174869
Summary Improve computeKnownFPClass handling of signbit patterns
Labels missed-optimization, floating-point
Assignees
Reporter arsenm
    Some library function code has sequence that extract sign bits and put them into the low position for use in later floating point operations. Currently computeKnownFPClass partially handles these, but fails to disprove some classes it could.

https://godbolt.org/z/hhhdKGnqc

```
; RUN: opt -S -p=attributor < %s

; Should only permit psub or pzero results, nofpclass(nan inf nzero nsub norm)
define float @signbit_only_psub(i32 %x) {
  %sign.bit = lshr i32 %x, 31
  %cast = bitcast i32 %sign.bit to float
 ret float %cast
}

; Should only permit psub results
define float @xor_signbit_only_psub(i32 %a, i32 %b) {
  %xor = xor i32 %a, %b
 %sign.bit = lshr i32 %xor, 31
  %cast = bitcast i32 %sign.bit to float
 ret float %cast
}
```


Currently the return attribute is inferred as `nofpclass(nan inf nzero nsub nnorm)`.  Since we know the value must be 0 or 1, this must be fcPosZero or fcPosSubnormal, the return attribute should be inferred as `nofpclass(nan inf nzero nsub norm)`, excluding positive normals.


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to