[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-04-10 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > I still have a few things to investigate to make sure of what is happening, > but in the meantime would you guys approve to land this patch to make the > implementation more stable whether the device supports denorm or not? > > ``` > - __CLC_INTN is_inf_nan_or_zero = > -

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-04-08 Thread Romaric Jodin via cfe-commits
rjodinchr wrote: I'm clearly seeing those devices returning true when comparing subnormals to zero. So either they all have a bug, or the SPIR-V code produced by `clspv` is buggy. If it ends up being a bug from the device, we might want to have something more architecture friendly, or at least

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-04-07 Thread Romaric Jodin via cfe-commits
rjodinchr wrote: I've deployed that patch into ChromeOS, and now Intel, Qualcomm and Imagination are also failing. I need to have a closer look to see if anything can be changed in `clspv` to fix it, but I might end-up needing the fix mentioned a few weeks ago. https://github.com/llvm/llvm-pr

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-20 Thread Romaric Jodin via cfe-commits
rjodinchr wrote: I tend to agree. let's keep it that way. https://github.com/llvm/llvm-project/pull/129871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-20 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: It strikes me as a swiftshader bug. If `x` is a denormal/subnormal number and it is being untouched by this function and really reaching this comparison as `0x1.008p-140` then I don't believe it should ever compare true against `0.0`. My reading of flush-to-zero ([here](htt

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-18 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: That's interesting. As I said alive2 was happy with the before/after IR diff of the AMDGPU version of this builtin. Do you know what might be going on? Is that the fp64 or fp32 test that's failing? https://github.com/llvm/llvm-project/pull/129871

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-18 Thread Matt Arsenault via cfe-commits
arsenm wrote: Is this failure using -cl-denorms-are-zero (IIRC -z when using math_brute_force) https://github.com/llvm/llvm-project/pull/129871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cf

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-18 Thread Romaric Jodin via cfe-commits
rjodinchr wrote: The following patch is fixing the issue on my side: ``` - __CLC_INTN is_inf_nan_or_zero = - x == __CLC_FP_LIT(0.0) || __clc_isinf(x) || __clc_isnan(x); + __CLC_INTN is_inf_nan_or_zero = + ai == (__CLC_INTN)0 || e == (__CLC_INTN)129 || __clc_isinf(x) || __clc_isnan(

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-18 Thread Romaric Jodin via cfe-commits
rjodinchr wrote: But maybe it is just masking a swiftshader bug? https://github.com/llvm/llvm-project/pull/129871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-18 Thread Romaric Jodin via cfe-commits
rjodinchr wrote: This is failing with `fp32`. The failing value is very close to zero (it's a denormal), I think something is going wrong with `x == __CLC_FP_LIT(0.0)` when computing `is_inf_nan_or_zero`. Maybe a bug inside Swiftshader with denormal comparison to zero? https://github.com/llvm/

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-17 Thread Romaric Jodin via cfe-commits
rjodinchr wrote: yes wrong results: ``` ERROR: frexp: {-8404992.00, 139} ulp error at 0x1.008p-140: *{0x1.008p-1, -139} vs. {0x1.008p-140, 0} ``` https://github.com/llvm/llvm-project/pull/129871 ___ cfe-commits mailing list cfe-commits@lists.llvm.

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-17 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > This commit breaks running with clvk & Swiftshader. Not a big deal on my > side. Just wanted to let you know. Oh, what exactly breaks? As in wrong results? https://github.com/llvm/llvm-project/pull/129871 ___ cfe-commits mailing

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-17 Thread Romaric Jodin via cfe-commits
rjodinchr wrote: This commit breaks running with clvk & Swiftshader. Not a big deal on my side. Just wanted to let you know. https://github.com/llvm/llvm-project/pull/129871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.or

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-05 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/129871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-05 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: It's worth noting that alive2 considers this a correct transformation for the before/after IR, for the scalar float/double versions of __clc_frexp for amdgcn. https://github.com/llvm/llvm-project/pull/129871 ___ cfe-commits mailing

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-05 Thread Matt Arsenault via cfe-commits
https://github.com/arsenm approved this pull request. I haven't spent much time looking at this one, because we have instructions for the two halves https://github.com/llvm/llvm-project/pull/129871 ___ cfe-commits mailing list cfe-commits@lists.llvm.

[libclc] [libclc] Reduce bithacking in CLC frexp (PR #129871)

2025-03-05 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/129871 Also replace some magic constants with named ones. Checking against FP zero and using isnan and isinf functions allows the optimizer to create one unified @llvm.is.fpclass intrinsic. This results in fewer