Skip to content

Fix extendhfxf2 test #117665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Fix extendhfxf2 test #117665

merged 1 commit into from
Nov 26, 2024

Conversation

biabbas
Copy link
Contributor

@biabbas biabbas commented Nov 26, 2024

Fix changes in #113897

cc @arichardson

Copy link

github-actions bot commented Nov 26, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fixes - I realize I didn't actually review the test properly.

@arichardson arichardson requested a review from rorth November 26, 2024 04:44
@biabbas biabbas force-pushed the main branch 4 times, most recently from 7b66a3b to 5b8b595 Compare November 26, 2024 05:38
Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit otherwise LGTM. Thanks!

int test_extendhfxf2(TYPE_FP16 a, xf_float expected) {
xf_float x = __extendhfxf2(a);
uint16_t a_rep = toRep16(a);
int ret = compareResultF80(x, expected);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this expects hi and lo. I'll have to change this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f80 functions in fp_test are only for x86_64

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes that should be relaxed to just be gated on fp80 support

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e. change the if in fp_test.h to just HAS_80_BIT_LONG_DOUBLE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the test exclusive for x86_64. Would __uint128_t be available on i386?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may or may not - but we shouldn't need it for this. I'll take care of that as a follo-up.

@biabbas biabbas force-pushed the main branch 3 times, most recently from 746db3b to 0a9032f Compare November 26, 2024 06:37
Copy link
Contributor

@abdulraheembeigh abdulraheembeigh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@mstorsjo
Copy link
Member

This change does fix tests on x86_64 mingw, but it still fails on i686 mingw, and it also breaks a number of previously working tests there - have a look: https://github.com/mstorsjo/llvm-project/actions/runs/12026429539/job/33525399943

You can try this out for yourself - cherrypick mstorsjo@gha-mingw-compiler-rt onto your branch and push to your fork, and it will run these tests in your own github fork (no PR needed even).

@@ -230,7 +230,7 @@ static inline double makeQNaN64(void)
return fromRep64(0x7ff8000000000000UL);
}

#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
#if HAS_80_BIT_LONG_DOUBLE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, we specifically checked for x86_64 here, but HAS_80_BIT_LONG_DOUBLE also is true on i686 mingw, so this will start executing these codepaths on i686 now as well.

Copy link
Contributor Author

@biabbas biabbas Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, https://github.com/mstorsjo/llvm-project/actions/runs/12026429539/job/33525399943 this suggests uint128t is not defined, thus this should be only enabled for x86_64.
Alternatively we could check if __uint128t is available with check_c_source_compiles and add another flag like we do here

check_c_source_compiles("_Float16 foo(_Float16 x) { return x; }
.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I also tested with an addition like this: mstorsjo@de5ad3a

That unbreaks the other unrelated tests, but this new test still is failing: https://github.com/mstorsjo/llvm-project/actions/runs/12026756315/job/33526363616

# | D:\a\llvm-project\llvm-project\compiler-rt\test\builtins\Unit\extendhfxf2_test.c:16:13: error: call to undeclared function 'compareResultF80'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
# |    16 |   int ret = compareResultF80(x, expectedHi, expectedLo);
# |       |             ^

So a similar condition would need to be added back to the condition within the actual test here as well.

@rorth
Copy link
Collaborator

rorth commented Nov 26, 2024

Things are similar on Solaris/amd64:

  Builtins-i386-sunos :: divdf3_test.c
  Builtins-i386-sunos :: divsc3_test.c
  Builtins-i386-sunos :: divsf3_test.c
  Builtins-i386-sunos :: extendhfsf2_test.c
  Builtins-i386-sunos :: extendhfxf2_test.c
  Builtins-i386-sunos :: truncdfhf2_test.c
  Builtins-i386-sunos :: truncdfsf2_test.c
  Builtins-i386-sunos :: truncsfhf2_test.c

AFAICS the failures are all for the same reason:

In file included from /vol/llvm/src/llvm-project/local/compiler-rt/test/builtins/Unit/divdf3_test.c:7:
/vol/llvm/src/llvm-project/local/compiler-rt/test/builtins/Unit/fp_test.h:235:5: error: use of undeclared identifier '__uint128_t'
  235 |     __uint128_t x = ((__uint128_t)hi << 64) + lo;
      |     ^

__uint128_t etc. isn't available on 32-bit x86 (not only on Solaris, same on Linux/x86_64 -m32).

@biabbas
Copy link
Contributor Author

biabbas commented Nov 26, 2024

I've added the necessary checks to the test case now.

@mstorsjo
Copy link
Member

I've added the necessary checks to the test case now.

Thanks! This version works for the mingw tests on i686 and x86_64.

Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, fp_test.h guards can be cleaned up later.

@arichardson arichardson merged commit 06d24da into llvm:main Nov 26, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants