-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[compiler-rt] Fix declarations of builtins in test files #161222
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Replace `long double` and `long double _Complex` with `fp_t` and `Qcomplex` in the test files. This prepares for reapplying 6567070 and running tests on targets where `fp_t` is not `long double`.
1b75740
to
e88cd4d
Compare
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions c -- compiler-rt/test/builtins/Unit/fixunstfdi_test.c compiler-rt/test/builtins/Unit/multc3_test.c
View the diff from clang-format here.diff --git a/compiler-rt/test/builtins/Unit/fixunstfdi_test.c b/compiler-rt/test/builtins/Unit/fixunstfdi_test.c
index 14f0f7f15..338375a6f 100644
--- a/compiler-rt/test/builtins/Unit/fixunstfdi_test.c
+++ b/compiler-rt/test/builtins/Unit/fixunstfdi_test.c
@@ -6,33 +6,32 @@
#if _ARCH_PPC || __aarch64__ || __arm64ec__
-#define QUAD_PRECISION
-#include "fp_lib.h"
+# define QUAD_PRECISION
+# include "fp_lib.h"
-#include "int_lib.h"
+# include "int_lib.h"
// Returns: convert a to a unsigned long long, rounding toward zero.
// Negative values all become zero.
// Assumption: fp_t is a 128 bit floating point type
// du_int is a 64 bit integral type
-// value in fp_t is representable in du_int or is negative
+// value in fp_t is representable in du_int or is negative
// (no range checking performed)
COMPILER_RT_ABI du_int __fixunstfdi(fp_t a);
-int test__fixunstfdi(fp_t a, du_int expected)
-{
- du_int x = __fixunstfdi(a);
- if (x != expected)
- printf("error in __fixunstfdi(%LA) = %llX, expected %llX\n",
- a, x, expected);
- return x != expected;
+int test__fixunstfdi(fp_t a, du_int expected) {
+ du_int x = __fixunstfdi(a);
+ if (x != expected)
+ printf("error in __fixunstfdi(%LA) = %llX, expected %llX\n", a, x,
+ expected);
+ return x != expected;
}
char assumption_1[sizeof(du_int) == 2*sizeof(su_int)] = {0};
char assumption_2[sizeof(du_int)*CHAR_BIT == 64] = {0};
-char assumption_3[sizeof(fp_t)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(fp_t) * CHAR_BIT == 128] = {0};
#endif
diff --git a/compiler-rt/test/builtins/Unit/multc3_test.c b/compiler-rt/test/builtins/Unit/multc3_test.c
index 5eec56dc4..689c2a3e5 100644
--- a/compiler-rt/test/builtins/Unit/multc3_test.c
+++ b/compiler-rt/test/builtins/Unit/multc3_test.c
@@ -6,344 +6,330 @@
#if _ARCH_PPC || __aarch64__ || __arm64ec__
-#define QUAD_PRECISION
-#include "fp_lib.h"
+# define QUAD_PRECISION
+# include "fp_lib.h"
-#include "int_lib.h"
-#include <math.h>
-#include <complex.h>
+# include "int_lib.h"
+# include <math.h>
+# include <complex.h>
// Returns: the product of a + ib and c + id
-COMPILER_RT_ABI Qcomplex
-__multc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d);
+COMPILER_RT_ABI Qcomplex __multc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d);
enum {zero, non_zero, inf, NaN, non_zero_nan};
-int
-classify(Qcomplex x)
-{
- if (x == 0)
- return zero;
- if (isinf(creall(x)) || isinf(cimagl(x)))
- return inf;
- if (isnan(creall(x)) && isnan(cimagl(x)))
- return NaN;
- if (isnan(creall(x)))
- {
- if (cimagl(x) == 0)
- return NaN;
- return non_zero_nan;
- }
- if (isnan(cimagl(x)))
- {
- if (creall(x) == 0)
- return NaN;
- return non_zero_nan;
- }
- return non_zero;
+int classify(Qcomplex x) {
+ if (x == 0)
+ return zero;
+ if (isinf(creall(x)) || isinf(cimagl(x)))
+ return inf;
+ if (isnan(creall(x)) && isnan(cimagl(x)))
+ return NaN;
+ if (isnan(creall(x))) {
+ if (cimagl(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ if (isnan(cimagl(x))) {
+ if (creall(x) == 0)
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
}
-int test__multc3(fp_t a, fp_t b, fp_t c, fp_t d)
-{
- Qcomplex r = __multc3(a, b, c, d);
-// printf("test__multc3(%Lf, %Lf, %Lf, %Lf) = %Lf + I%Lf\n",
-// a, b, c, d, creall(r), cimagl(r));
- Qcomplex dividend;
- Qcomplex divisor;
-
- __real__ dividend = a;
- __imag__ dividend = b;
- __real__ divisor = c;
- __imag__ divisor = d;
-
- switch (classify(dividend))
- {
+int test__multc3(fp_t a, fp_t b, fp_t c, fp_t d) {
+ Qcomplex r = __multc3(a, b, c, d);
+ // printf("test__multc3(%Lf, %Lf, %Lf, %Lf) = %Lf + I%Lf\n",
+ // a, b, c, d, creall(r), cimagl(r));
+ Qcomplex dividend;
+ Qcomplex divisor;
+
+ __real__ dividend = a;
+ __imag__ dividend = b;
+ __real__ divisor = c;
+ __imag__ divisor = d;
+
+ switch (classify(dividend)) {
+ case zero:
+ switch (classify(divisor)) {
case zero:
- switch (classify(divisor))
- {
- case zero:
- if (classify(r) != zero)
- return 1;
- break;
- case non_zero:
- if (classify(r) != zero)
- return 1;
- break;
- case inf:
- if (classify(r) != NaN)
- return 1;
- break;
- case NaN:
- if (classify(r) != NaN)
- return 1;
- break;
- case non_zero_nan:
- if (classify(r) != NaN)
- return 1;
- break;
- }
- break;
+ if (classify(r) != zero)
+ return 1;
+ break;
case non_zero:
- switch (classify(divisor))
- {
- case zero:
- if (classify(r) != zero)
- return 1;
- break;
- case non_zero:
- if (classify(r) != non_zero)
- return 1;
- if (r != a * c - b * d + _Complex_I*(a * d + b * c))
- return 1;
- break;
- case inf:
- if (classify(r) != inf)
- return 1;
- break;
- case NaN:
- if (classify(r) != NaN)
- return 1;
- break;
- case non_zero_nan:
- if (classify(r) != NaN)
- return 1;
- break;
- }
- break;
+ if (classify(r) != zero)
+ return 1;
+ break;
case inf:
- switch (classify(divisor))
- {
- case zero:
- if (classify(r) != NaN)
- return 1;
- break;
- case non_zero:
- if (classify(r) != inf)
- return 1;
- break;
- case inf:
- if (classify(r) != inf)
- return 1;
- break;
- case NaN:
- if (classify(r) != NaN)
- return 1;
- break;
- case non_zero_nan:
- if (classify(r) != inf)
- return 1;
- break;
- }
- break;
+ if (classify(r) != NaN)
+ return 1;
+ break;
case NaN:
- switch (classify(divisor))
- {
- case zero:
- if (classify(r) != NaN)
- return 1;
- break;
- case non_zero:
- if (classify(r) != NaN)
- return 1;
- break;
- case inf:
- if (classify(r) != NaN)
- return 1;
- break;
- case NaN:
- if (classify(r) != NaN)
- return 1;
- break;
- case non_zero_nan:
- if (classify(r) != NaN)
- return 1;
- break;
- }
- break;
+ if (classify(r) != NaN)
+ return 1;
+ break;
case non_zero_nan:
- switch (classify(divisor))
- {
- case zero:
- if (classify(r) != NaN)
- return 1;
- break;
- case non_zero:
- if (classify(r) != NaN)
- return 1;
- break;
- case inf:
- if (classify(r) != inf)
- return 1;
- break;
- case NaN:
- if (classify(r) != NaN)
- return 1;
- break;
- case non_zero_nan:
- if (classify(r) != NaN)
- return 1;
- break;
- }
- break;
+ if (classify(r) != NaN)
+ return 1;
+ break;
}
-
- return 0;
+ break;
+ case non_zero:
+ switch (classify(divisor)) {
+ case zero:
+ if (classify(r) != zero)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != non_zero)
+ return 1;
+ if (r != a * c - b * d + _Complex_I * (a * d + b * c))
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(divisor)) {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(divisor)) {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(divisor)) {
+ case zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case inf:
+ if (classify(r) != inf)
+ return 1;
+ break;
+ case NaN:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ case non_zero_nan:
+ if (classify(r) != NaN)
+ return 1;
+ break;
+ }
+ break;
+ }
+
+ return 0;
}
-fp_t x[][2] =
-{
- { 1.e-6, 1.e-6},
- {-1.e-6, 1.e-6},
- {-1.e-6, -1.e-6},
- { 1.e-6, -1.e-6},
+fp_t x[][2] = {{1.e-6, 1.e-6},
+ {-1.e-6, 1.e-6},
+ {-1.e-6, -1.e-6},
+ {1.e-6, -1.e-6},
- { 1.e+6, 1.e-6},
- {-1.e+6, 1.e-6},
- {-1.e+6, -1.e-6},
- { 1.e+6, -1.e-6},
+ {1.e+6, 1.e-6},
+ {-1.e+6, 1.e-6},
+ {-1.e+6, -1.e-6},
+ {1.e+6, -1.e-6},
- { 1.e-6, 1.e+6},
- {-1.e-6, 1.e+6},
- {-1.e-6, -1.e+6},
- { 1.e-6, -1.e+6},
+ {1.e-6, 1.e+6},
+ {-1.e-6, 1.e+6},
+ {-1.e-6, -1.e+6},
+ {1.e-6, -1.e+6},
- { 1.e+6, 1.e+6},
- {-1.e+6, 1.e+6},
- {-1.e+6, -1.e+6},
- { 1.e+6, -1.e+6},
+ {1.e+6, 1.e+6},
+ {-1.e+6, 1.e+6},
+ {-1.e+6, -1.e+6},
+ {1.e+6, -1.e+6},
- {NAN, NAN},
- {-INFINITY, NAN},
- {-2, NAN},
- {-1, NAN},
- {-0.5, NAN},
- {-0., NAN},
- {+0., NAN},
- {0.5, NAN},
- {1, NAN},
- {2, NAN},
- {INFINITY, NAN},
+ {NAN, NAN},
+ {-INFINITY, NAN},
+ {-2, NAN},
+ {-1, NAN},
+ {-0.5, NAN},
+ {-0., NAN},
+ {+0., NAN},
+ {0.5, NAN},
+ {1, NAN},
+ {2, NAN},
+ {INFINITY, NAN},
- {NAN, -INFINITY},
- {-INFINITY, -INFINITY},
- {-2, -INFINITY},
- {-1, -INFINITY},
- {-0.5, -INFINITY},
- {-0., -INFINITY},
- {+0., -INFINITY},
- {0.5, -INFINITY},
- {1, -INFINITY},
- {2, -INFINITY},
- {INFINITY, -INFINITY},
+ {NAN, -INFINITY},
+ {-INFINITY, -INFINITY},
+ {-2, -INFINITY},
+ {-1, -INFINITY},
+ {-0.5, -INFINITY},
+ {-0., -INFINITY},
+ {+0., -INFINITY},
+ {0.5, -INFINITY},
+ {1, -INFINITY},
+ {2, -INFINITY},
+ {INFINITY, -INFINITY},
- {NAN, -2},
- {-INFINITY, -2},
- {-2, -2},
- {-1, -2},
- {-0.5, -2},
- {-0., -2},
- {+0., -2},
- {0.5, -2},
- {1, -2},
- {2, -2},
- {INFINITY, -2},
+ {NAN, -2},
+ {-INFINITY, -2},
+ {-2, -2},
+ {-1, -2},
+ {-0.5, -2},
+ {-0., -2},
+ {+0., -2},
+ {0.5, -2},
+ {1, -2},
+ {2, -2},
+ {INFINITY, -2},
- {NAN, -1},
- {-INFINITY, -1},
- {-2, -1},
- {-1, -1},
- {-0.5, -1},
- {-0., -1},
- {+0., -1},
- {0.5, -1},
- {1, -1},
- {2, -1},
- {INFINITY, -1},
+ {NAN, -1},
+ {-INFINITY, -1},
+ {-2, -1},
+ {-1, -1},
+ {-0.5, -1},
+ {-0., -1},
+ {+0., -1},
+ {0.5, -1},
+ {1, -1},
+ {2, -1},
+ {INFINITY, -1},
- {NAN, -0.5},
- {-INFINITY, -0.5},
- {-2, -0.5},
- {-1, -0.5},
- {-0.5, -0.5},
- {-0., -0.5},
- {+0., -0.5},
- {0.5, -0.5},
- {1, -0.5},
- {2, -0.5},
- {INFINITY, -0.5},
+ {NAN, -0.5},
+ {-INFINITY, -0.5},
+ {-2, -0.5},
+ {-1, -0.5},
+ {-0.5, -0.5},
+ {-0., -0.5},
+ {+0., -0.5},
+ {0.5, -0.5},
+ {1, -0.5},
+ {2, -0.5},
+ {INFINITY, -0.5},
- {NAN, -0.},
- {-INFINITY, -0.},
- {-2, -0.},
- {-1, -0.},
- {-0.5, -0.},
- {-0., -0.},
- {+0., -0.},
- {0.5, -0.},
- {1, -0.},
- {2, -0.},
- {INFINITY, -0.},
+ {NAN, -0.},
+ {-INFINITY, -0.},
+ {-2, -0.},
+ {-1, -0.},
+ {-0.5, -0.},
+ {-0., -0.},
+ {+0., -0.},
+ {0.5, -0.},
+ {1, -0.},
+ {2, -0.},
+ {INFINITY, -0.},
- {NAN, 0.},
- {-INFINITY, 0.},
- {-2, 0.},
- {-1, 0.},
- {-0.5, 0.},
- {-0., 0.},
- {+0., 0.},
- {0.5, 0.},
- {1, 0.},
- {2, 0.},
- {INFINITY, 0.},
+ {NAN, 0.},
+ {-INFINITY, 0.},
+ {-2, 0.},
+ {-1, 0.},
+ {-0.5, 0.},
+ {-0., 0.},
+ {+0., 0.},
+ {0.5, 0.},
+ {1, 0.},
+ {2, 0.},
+ {INFINITY, 0.},
- {NAN, 0.5},
- {-INFINITY, 0.5},
- {-2, 0.5},
- {-1, 0.5},
- {-0.5, 0.5},
- {-0., 0.5},
- {+0., 0.5},
- {0.5, 0.5},
- {1, 0.5},
- {2, 0.5},
- {INFINITY, 0.5},
+ {NAN, 0.5},
+ {-INFINITY, 0.5},
+ {-2, 0.5},
+ {-1, 0.5},
+ {-0.5, 0.5},
+ {-0., 0.5},
+ {+0., 0.5},
+ {0.5, 0.5},
+ {1, 0.5},
+ {2, 0.5},
+ {INFINITY, 0.5},
- {NAN, 1},
- {-INFINITY, 1},
- {-2, 1},
- {-1, 1},
- {-0.5, 1},
- {-0., 1},
- {+0., 1},
- {0.5, 1},
- {1, 1},
- {2, 1},
- {INFINITY, 1},
+ {NAN, 1},
+ {-INFINITY, 1},
+ {-2, 1},
+ {-1, 1},
+ {-0.5, 1},
+ {-0., 1},
+ {+0., 1},
+ {0.5, 1},
+ {1, 1},
+ {2, 1},
+ {INFINITY, 1},
- {NAN, 2},
- {-INFINITY, 2},
- {-2, 2},
- {-1, 2},
- {-0.5, 2},
- {-0., 2},
- {+0., 2},
- {0.5, 2},
- {1, 2},
- {2, 2},
- {INFINITY, 2},
+ {NAN, 2},
+ {-INFINITY, 2},
+ {-2, 2},
+ {-1, 2},
+ {-0.5, 2},
+ {-0., 2},
+ {+0., 2},
+ {0.5, 2},
+ {1, 2},
+ {2, 2},
+ {INFINITY, 2},
- {NAN, INFINITY},
- {-INFINITY, INFINITY},
- {-2, INFINITY},
- {-1, INFINITY},
- {-0.5, INFINITY},
- {-0., INFINITY},
- {+0., INFINITY},
- {0.5, INFINITY},
- {1, INFINITY},
- {2, INFINITY},
- {INFINITY, INFINITY}
+ {NAN, INFINITY},
+ {-INFINITY, INFINITY},
+ {-2, INFINITY},
+ {-1, INFINITY},
+ {-0.5, INFINITY},
+ {-0., INFINITY},
+ {+0., INFINITY},
+ {0.5, INFINITY},
+ {1, INFINITY},
+ {2, INFINITY},
+ {INFINITY, INFINITY}
};
|
We need this change if we want to run the tests on |
jroelofs
approved these changes
Sep 29, 2025
mahesh-attarde
pushed a commit
to mahesh-attarde/llvm-project
that referenced
this pull request
Oct 3, 2025
Replace `long double` and `long double _Complex` with `fp_t` and `Qcomplex` in the test files. This prepares for reapplying 6567070 and running tests on targets where `fp_t` is not `long double`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replace
long double
andlong double _Complex
withfp_t
andQcomplex
in the test files.This prepares for reapplying 6567070 and running tests on targets where
fp_t
is notlong double
.