]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/119532 - ICE with fixed-point tail recursion
authorRichard Biener <rguenther@suse.de>
Mon, 31 Mar 2025 08:02:27 +0000 (10:02 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 31 Mar 2025 11:27:28 +0000 (13:27 +0200)
The following disables tail recursion optimization when fixed-point
types are involved as we cannot generate -1 for all fixed-point
types.

PR tree-optimization/119532
* tree-tailcall.cc (process_assignment): FAIL for fixed-point
typed functions.

* gcc.dg/torture/pr119532.c: New testcase.

gcc/testsuite/gcc.dg/torture/pr119532.c [new file with mode: 0644]
gcc/tree-tailcall.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr119532.c b/gcc/testsuite/gcc.dg/torture/pr119532.c
new file mode 100644 (file)
index 0000000..bba2e45
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target fixed_point } */
+
+extern _Fract sinuhk_deg (unsigned short _Accum);
+
+_Fract cosuhk_deg (unsigned short _Accum deg)
+{
+  unsigned short _Accum _90_deg = 90uhk;
+  __asm ("" : "+r" (_90_deg));
+
+  return deg <= _90_deg
+    ? sinuhk_deg (_90_deg - deg)
+    : -sinuhk_deg (deg - _90_deg);
+}
index 8ba6752219153b0dbaf1adc53149b2fe304ea3db..8ea1c8b5f99fe695296e416aebea599b5f8ccdcb 100644 (file)
@@ -361,6 +361,10 @@ process_assignment (gassign *stmt,
     if (FLOAT_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl))))
       return FAIL;
 
+  /* We at least cannot build -1 for all fixed point types.  */
+  if (FIXED_POINT_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl))))
+    return FAIL;
+
   if (rhs_class == GIMPLE_UNARY_RHS
       && op0 == *ass_var)
     ;