[gcc r14-12463] tree-optimization/119532 - ICE with fixed-point tail recursion
Richard Biener
rguenth@gcc.gnu.org
Fri Mar 20 11:29:08 GMT 2026
https://gcc.gnu.org/g:31e6033ba8324737ab3acaf909533c64fe43d55e
commit r14-12463-g31e6033ba8324737ab3acaf909533c64fe43d55e
Author: Richard Biener <rguenther@suse.de>
Date: Mon Mar 31 10:02:27 2025 +0200
tree-optimization/119532 - ICE with fixed-point tail recursion
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.
(cherry picked from commit 95c25cb09f58810bc520c3db469945c6a751aa32)
Diff:
---
gcc/testsuite/gcc.dg/torture/pr119532.c | 14 ++++++++++++++
gcc/tree-tailcall.cc | 4 ++++
2 files changed, 18 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/torture/pr119532.c b/gcc/testsuite/gcc.dg/torture/pr119532.c
new file mode 100644
index 000000000000..bba2e451d2b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr119532.c
@@ -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);
+}
diff --git a/gcc/tree-tailcall.cc b/gcc/tree-tailcall.cc
index e9f7f8a12b3a..747c9020ee2a 100644
--- a/gcc/tree-tailcall.cc
+++ b/gcc/tree-tailcall.cc
@@ -329,6 +329,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)
;
More information about the Gcc-cvs
mailing list