This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][aarch64] New tests for 128-bit floating-point builtins, fixes of tests and __fixuint
ClosedPublic

Authored by sdmitrouk on Oct 29 2015, 3:11 PM.

Details

Summary

The following tests for 128-bit floating-point type behaved in a strange way, thought it were bugs, but seem to be mistakes in tests:

  • fixtfsi test checked for 0x80000001 as a value returned for number less than can be represented, while LONG_MIN should be returned on saturation;
  • fixunstfdi wasn't enabled for AArch64, only for PPC, but there is nothing PPC specific in that test;
  • multf3 tried to underflow multiplication by producing result with 16383 exponent, while there are still 112 bits of fraction plus implicit bit, so resultant exponent should be 16497.

Tests for some other builtins didn't exist:

  • fixtfdi
  • fixtfti
  • fixunstfti

They were made by copying similar files and adjusting for wider types and adding/removing some reasonable/extra checks.

Also __fixuint seems to have off by one error, updated tests to catch this case.

Diff Detail

Repository
rL LLVM

Event Timeline

sdmitrouk updated this revision to Diff 38767.Oct 29 2015, 3:11 PM
sdmitrouk retitled this revision from to [compiler-rt][aarch64] New tests for 128-bit floating-point builtins and fixes of tests.
sdmitrouk updated this object.
sdmitrouk set the repository for this revision to rL LLVM.
sdmitrouk added a subscriber: llvm-commits.
zatrazz added inline comments.Nov 1 2015, 11:15 AM
test/builtins/Unit/fixunstfti_test.c
88 ↗(On Diff #38767)

Shouldn't it be (0xFFFFFF0000000000, 0x0)?

sdmitrouk updated this revision to Diff 39183.Nov 4 2015, 4:09 AM
sdmitrouk retitled this revision from [compiler-rt][aarch64] New tests for 128-bit floating-point builtins and fixes of tests to [compiler-rt][aarch64] New tests for 128-bit floating-point builtins, fixes of tests and __fixuint.
sdmitrouk updated this object.

Fixed off by one error in __fixuint and updated eight tests to check this case (expected 1...1 n times on input 2^n where n is width of output type in bits).

sdmitrouk marked an inline comment as done.Nov 4 2015, 4:13 AM

Somehow missed the inline comment.

test/builtins/Unit/fixunstfti_test.c
89 ↗(On Diff #39183)

Actually it should be (0xffffffffffffffffLL, 0xffffffffffffffffLL) because input is larger than 2^128. __fixuint seems to have off by one error when checking for too large exponent (used > instead of >=), updated revision to address this. Thanks!

zatrazz added inline comments.Nov 5 2015, 8:26 AM
test/builtins/Unit/fixunstfti_test.c
89 ↗(On Diff #39183)

Unless I am missing something here, the code:

void
func (void)
{
  mpfr_t number;
  mpfr_init2 (number, PRECISION);
  mpfr_set_ld (number, 0x1.FFFFFEp+127, MPFR_RNDN);
  mpfr_printf ("%Rf\n", number);

  mpz_t integer;
  mpz_init2 (integer, PRECISION);
  mpfr_get_z (integer, number, MPFR_RNDN);

  mpfr_printf ("float:   %Rf\n", number);
  mpfr_printf ("integer: %033ZX\n", integer);
}

Prints on a aarch64 machine:

float: 340282346638528859811704183484516925440.000000
integer: 0FFFFFF00000000000000000000000000

And the maximum value of an uint128_t is:

340282366920938463463374607431768211455L

So the value is still lower than 128 *unsigned* bits.

sdmitrouk marked an inline comment as done.Nov 5 2015, 9:34 AM
sdmitrouk added inline comments.
test/builtins/Unit/fixunstfti_test.c
89 ↗(On Diff #39183)

I'm not sure I follow, your example confirms the line below:

if (test__fixunstfti(0x1.FFFFFEp+127, make_ti(0xffffff0000000000LL, 0x0)))

but your first comment was about this line:

if (test__fixunstfti(0x1.FFFFFEp+128, make_ti(0xfffffe0000000000LL, 0x0)))

which is 1FFFFFE00000000000000000000000000 (33 nibbles) in integer form. The most significant bit used to be truncated (same happened for unsigned si and di), which is fixed by second revision.

zatrazz added inline comments.Nov 5 2015, 10:21 AM
test/builtins/Unit/fixunstfti_test.c
89 ↗(On Diff #39183)

Ah right, my confusion here. LGTM now.

This revision was automatically updated to reflect the committed changes.