Skip to content

Conversation

@statham-arm
Copy link
Collaborator

Reverts #161546

One of the buildbots reported a cmake error I don't understand, and which I didn't get in my own test builds:

CMake Error at /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/compiler-rt/cmake/Modules/CheckAssemblerFlag.cmake:23 (try_compile):
  COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE

My best guess is that the thing I did in CheckAssemblerFlag.cmake only works on some versions of cmake. But I don't understand the problem well enough to fix it quickly, so I'm reverting the whole patch and will reland it later.

@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions c -- compiler-rt/test/builtins/Unit/divsf3_test.c --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/compiler-rt/test/builtins/Unit/divsf3_test.c b/compiler-rt/test/builtins/Unit/divsf3_test.c
index f8cb6169a..e4a227976 100644
--- a/compiler-rt/test/builtins/Unit/divsf3_test.c
+++ b/compiler-rt/test/builtins/Unit/divsf3_test.c
@@ -9,107 +9,105 @@
 // Returns: a / b
 COMPILER_RT_ABI float __divsf3(float a, float b);
 
-int test__divsf3(float a, float b, uint32_t expected)
-{
-    float x = __divsf3(a, b);
-    int ret = compareResultF(x, expected);
-
-    if (ret){
-        printf("error in test__divsf3(%.20e, %.20e) = %.20e, "
-               "expected %.20e\n", a, b, x,
-               fromRep32(expected));
-    }
-    return ret;
+int test__divsf3(float a, float b, uint32_t expected) {
+  float x = __divsf3(a, b);
+  int ret = compareResultF(x, expected);
+
+  if (ret) {
+    printf("error in test__divsf3(%.20e, %.20e) = %.20e, "
+           "expected %.20e\n",
+           a, b, x, fromRep32(expected));
+  }
+  return ret;
 }
 
-int main()
-{
-    // Returned NaNs are assumed to be qNaN by default
-
-    // qNaN / any = qNaN
-    if (test__divsf3(makeQNaN32(), 3.F, UINT32_C(0x7fc00000)))
-      return 1;
-    // NaN / any = NaN
-    if (test__divsf3(makeNaN32(UINT32_C(0x123)), 3.F, UINT32_C(0x7fc00000)))
-      return 1;
-    // any / qNaN = qNaN
-    if (test__divsf3(3.F, makeQNaN32(), UINT32_C(0x7fc00000)))
-      return 1;
-    // any / NaN = NaN
-    if (test__divsf3(3.F, makeNaN32(UINT32_C(0x123)), UINT32_C(0x7fc00000)))
-      return 1;
-
-    // +Inf / positive = +Inf
-    if (test__divsf3(makeInf32(), 3.F, UINT32_C(0x7f800000)))
-      return 1;
-    // +Inf / negative = -Inf
-    if (test__divsf3(makeInf32(), -3.F, UINT32_C(0xff800000)))
-      return 1;
-    // -Inf / positive = -Inf
-    if (test__divsf3(makeNegativeInf32(), 3.F, UINT32_C(0xff800000)))
-      return 1;
-    // -Inf / negative = +Inf
-    if (test__divsf3(makeNegativeInf32(), -3.F, UINT32_C(0x7f800000)))
-      return 1;
-
-    // Inf / Inf = NaN
-    if (test__divsf3(makeInf32(), makeInf32(), UINT32_C(0x7fc00000)))
-      return 1;
-    // 0.0 / 0.0 = NaN
-    if (test__divsf3(+0x0.0p+0F, +0x0.0p+0F, UINT32_C(0x7fc00000)))
-      return 1;
-    // +0.0 / +Inf = +0.0
-    if (test__divsf3(+0x0.0p+0F, makeInf32(), UINT32_C(0x0)))
-      return 1;
-    // +Inf / +0.0 = +Inf
-    if (test__divsf3(makeInf32(), +0x0.0p+0F, UINT32_C(0x7f800000)))
-      return 1;
-
-    // positive / +0.0 = +Inf
-    if (test__divsf3(+1.F, +0x0.0p+0F, UINT32_C(0x7f800000)))
-      return 1;
-    // positive / -0.0 = -Inf
-    if (test__divsf3(+1.F, -0x0.0p+0F, UINT32_C(0xff800000)))
-      return 1;
-    // negative / +0.0 = -Inf
-    if (test__divsf3(-1.F, +0x0.0p+0F, UINT32_C(0xff800000)))
-      return 1;
-    // negative / -0.0 = +Inf
-    if (test__divsf3(-1.F, -0x0.0p+0F, UINT32_C(0x7f800000)))
-      return 1;
-
-    // 1/3
-    if (test__divsf3(1.F, 3.F, UINT32_C(0x3eaaaaab)))
-      return 1;
-    // smallest normal result
-    if (test__divsf3(0x1.0p-125F, 2.F, UINT32_C(0x00800000)))
-      return 1;
-
-    // divisor is exactly 1.0
-    if (test__divsf3(0x1.0p+0F, 0x1.0p+0F, UINT32_C(0x3f800000)))
-      return 1;
-    // divisor is truncated to exactly 1.0 in UQ1.15
-    if (test__divsf3(0x1.0p+0F, 0x1.0001p+0F, UINT32_C(0x3f7fff00)))
-      return 1;
-
-    // smallest normal value divided by 2.0
-    if (test__divsf3(0x1.0p-126F, 2.0F, UINT32_C(0x00400000)))
-      return 1;
-    // smallest subnormal result
-    if (test__divsf3(0x1.0p-126F, 0x1p+23F, UINT32_C(0x00000001)))
-      return 1;
-
-    // some misc test cases obtained by fuzzing against h/w implementation
-    if (test__divsf3(-0x1.3e75e6p-108F, -0x1.cf372p+38F, UINT32_C(0x00000006)))
-      return 1;
-    if (test__divsf3(0x1.e77c54p+81F, -0x1.e77c52p-47F, UINT32_C(0xff800000)))
-      return 1;
-    if (test__divsf3(0x1.fffffep-126F, 2.F, UINT32_C(0x00800000)))
-      return 1;
-
-    // test 1 / (1 - eps(0.5)) = 1 + eps(1)
-    if (test__divsf3(1.0F, 0x1.fffffep-1F, UINT32_C(0x3f800001)))
-      return 1;
-
-    return 0;
+int main() {
+  // Returned NaNs are assumed to be qNaN by default
+
+  // qNaN / any = qNaN
+  if (test__divsf3(makeQNaN32(), 3.F, UINT32_C(0x7fc00000)))
+    return 1;
+  // NaN / any = NaN
+  if (test__divsf3(makeNaN32(UINT32_C(0x123)), 3.F, UINT32_C(0x7fc00000)))
+    return 1;
+  // any / qNaN = qNaN
+  if (test__divsf3(3.F, makeQNaN32(), UINT32_C(0x7fc00000)))
+    return 1;
+  // any / NaN = NaN
+  if (test__divsf3(3.F, makeNaN32(UINT32_C(0x123)), UINT32_C(0x7fc00000)))
+    return 1;
+
+  // +Inf / positive = +Inf
+  if (test__divsf3(makeInf32(), 3.F, UINT32_C(0x7f800000)))
+    return 1;
+  // +Inf / negative = -Inf
+  if (test__divsf3(makeInf32(), -3.F, UINT32_C(0xff800000)))
+    return 1;
+  // -Inf / positive = -Inf
+  if (test__divsf3(makeNegativeInf32(), 3.F, UINT32_C(0xff800000)))
+    return 1;
+  // -Inf / negative = +Inf
+  if (test__divsf3(makeNegativeInf32(), -3.F, UINT32_C(0x7f800000)))
+    return 1;
+
+  // Inf / Inf = NaN
+  if (test__divsf3(makeInf32(), makeInf32(), UINT32_C(0x7fc00000)))
+    return 1;
+  // 0.0 / 0.0 = NaN
+  if (test__divsf3(+0x0.0p+0F, +0x0.0p+0F, UINT32_C(0x7fc00000)))
+    return 1;
+  // +0.0 / +Inf = +0.0
+  if (test__divsf3(+0x0.0p+0F, makeInf32(), UINT32_C(0x0)))
+    return 1;
+  // +Inf / +0.0 = +Inf
+  if (test__divsf3(makeInf32(), +0x0.0p+0F, UINT32_C(0x7f800000)))
+    return 1;
+
+  // positive / +0.0 = +Inf
+  if (test__divsf3(+1.F, +0x0.0p+0F, UINT32_C(0x7f800000)))
+    return 1;
+  // positive / -0.0 = -Inf
+  if (test__divsf3(+1.F, -0x0.0p+0F, UINT32_C(0xff800000)))
+    return 1;
+  // negative / +0.0 = -Inf
+  if (test__divsf3(-1.F, +0x0.0p+0F, UINT32_C(0xff800000)))
+    return 1;
+  // negative / -0.0 = +Inf
+  if (test__divsf3(-1.F, -0x0.0p+0F, UINT32_C(0x7f800000)))
+    return 1;
+
+  // 1/3
+  if (test__divsf3(1.F, 3.F, UINT32_C(0x3eaaaaab)))
+    return 1;
+  // smallest normal result
+  if (test__divsf3(0x1.0p-125F, 2.F, UINT32_C(0x00800000)))
+    return 1;
+
+  // divisor is exactly 1.0
+  if (test__divsf3(0x1.0p+0F, 0x1.0p+0F, UINT32_C(0x3f800000)))
+    return 1;
+  // divisor is truncated to exactly 1.0 in UQ1.15
+  if (test__divsf3(0x1.0p+0F, 0x1.0001p+0F, UINT32_C(0x3f7fff00)))
+    return 1;
+
+  // smallest normal value divided by 2.0
+  if (test__divsf3(0x1.0p-126F, 2.0F, UINT32_C(0x00400000)))
+    return 1;
+  // smallest subnormal result
+  if (test__divsf3(0x1.0p-126F, 0x1p+23F, UINT32_C(0x00000001)))
+    return 1;
+
+  // some misc test cases obtained by fuzzing against h/w implementation
+  if (test__divsf3(-0x1.3e75e6p-108F, -0x1.cf372p+38F, UINT32_C(0x00000006)))
+    return 1;
+  if (test__divsf3(0x1.e77c54p+81F, -0x1.e77c52p-47F, UINT32_C(0xff800000)))
+    return 1;
+  if (test__divsf3(0x1.fffffep-126F, 2.F, UINT32_C(0x00800000)))
+    return 1;
+
+  // test 1 / (1 - eps(0.5)) = 1 + eps(1)
+  if (test__divsf3(1.0F, 0x1.fffffep-1F, UINT32_C(0x3f800001)))
+    return 1;
+
+  return 0;
 }

@statham-arm
Copy link
Collaborator Author

I have to land this revert without CI being happy, because if nothing else, the code formatting check is never going to be happy – a side effect of the patch I'm reverting was to fix the code formatting in an existing test file!

@statham-arm statham-arm merged commit 1c19645 into main Nov 13, 2025
6 of 10 checks passed
@statham-arm statham-arm deleted the revert-161546-optimized-float-mul-div branch November 13, 2025 16:58
@statham-arm
Copy link
Collaborator Author

OK, now I understand what that error message meant! The problem is that the Fuchsia buildbot is using cmake 3.22.1 (from Ubuntu 22.04), and the form of try_compile I used in my patch appeared in a later version, cmake 3.25.

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.

3 participants