Skip to content

[X86][clang] 128bit floating-point operations in x86 machines #77401

Description

@CoTinker

testcase:

#include <fenv.h>
#include <stdlib.h>
#include <stdio.h>

int main (void)
{
  volatile __float128 a = 0x0.fffp-16382q, b = 0x0.fffp0q, c;
  c = a / b;
  if (fetestexcept (FE_UNDERFLOW | FE_INEXACT))
    printf("Fail1\n");
  if (c != 0x1p-16382q)
    printf("Fail2\n");
  exit (0);
}

compile command:

% clang test.c -o test -lm -m32
% ./test
Fail1
Fail2

compile in x86_64 will return normally, but x86 output Fail.
https://godbolt.org/z/vhdsMhd8d

Activity

  1. added
    clangClang issues not falling into any other category
    on Jan 9, 2024
  2. added and removed
    clangClang issues not falling into any other category
    on Jan 9, 2024
  3. llvmbot commented on Jan 9, 2024

    @llvmbot
    Member

    @llvm/issue-subscribers-backend-x86

    Author: Longsheng Mou (CoTinker)

    Details testcase:
    #include &lt;fenv.h&gt;
    #include &lt;stdlib.h&gt;
    #include &lt;stdio.h&gt;
    
    int main (void)
    {
      volatile __float128 a = 0x0.fffp-16382q, b = 0x0.fffp0q, c;
      c = a / b;
      if (fetestexcept (FE_UNDERFLOW | FE_INEXACT))
        printf("Fail1\n");
      if (c != 0x1p-16382q)
        printf("Fail2\n");
      exit (0);
    }
    

    compile command:

    % clang test.c -o test -lm -m32
    % ./test
    Fail1
    Fail2
    

    compile in x86_64 will return normally, but x86 output Fail.
    https://godbolt.org/z/vhdsMhd8d

  4. arsenm commented on Jan 9, 2024

    @arsenm
    Contributor

    Technically you need to enable FENV_ACCESS for this program

  5. CoTinker commented on Jan 9, 2024

    @CoTinker
    ContributorAuthor

    Technically you need to enable FENV_ACCESS for this program

    #pragma STDC FENV_ACCESS ON
    It seems not work.

  6. CoTinker commented on Jan 15, 2024

    @CoTinker
    ContributorAuthor
  7. hstk30-hw commented on Jan 20, 2024

    @hstk30-hw
    Contributor

    @arsenm Hi, enable FENV_ACCESS still fail. Does FENV_ACCESS supported in m32 ?
    https://godbolt.org/z/MsYTe1cPc

  8. hstk30-hw commented on Jan 22, 2024

    @hstk30-hw
    Contributor
  9. hstk30-hw commented on Jan 30, 2024

    @hstk30-hw
    Contributor

    https://godbolt.org/z/4KbaWcvsG

    I see the asm, clang x86 with m32 abi is not compatible with libgcc.

  10. hstk30-hw commented on Jan 30, 2024

    @hstk30-hw
    Contributor
  11. arsenm commented on Feb 1, 2024

    @arsenm
    Contributor

    @arsenm Hi, enable FENV_ACCESS still fail. Does FENV_ACCESS supported in m32 ? https://godbolt.org/z/MsYTe1cPc

    I think it should work the same as x64

  12. hstk30-hw commented on Feb 1, 2024

    @hstk30-hw
    Contributor

    In fact, not work! I guess float128 (long double) not align to 16 in x86-32.
    I'm reading the x86 isel dag->dag pass, maybe lowering mir gets mistake in the step.

  13. hstk30-hw commented on Feb 1, 2024

    @hstk30-hw
    Contributor

    Do you have any idea about this problem?
    It seems a legacy.
    https://lists.llvm.org/pipermail/llvm-dev/2016-December/108033.html
    Seems no body care about x86-32? @arsenm

  14. 16 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions