Skip to content

Commit 95c25cb

Browse files
rguenthRichard Biener
authored and
Richard Biener
committed
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.
1 parent f30e180 commit 95c25cb

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* { dg-do compile } */
2+
/* { dg-require-effective-target fixed_point } */
3+
4+
extern _Fract sinuhk_deg (unsigned short _Accum);
5+
6+
_Fract cosuhk_deg (unsigned short _Accum deg)
7+
{
8+
unsigned short _Accum _90_deg = 90uhk;
9+
__asm ("" : "+r" (_90_deg));
10+
11+
return deg <= _90_deg
12+
? sinuhk_deg (_90_deg - deg)
13+
: -sinuhk_deg (deg - _90_deg);
14+
}

gcc/tree-tailcall.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ process_assignment (gassign *stmt,
361361
if (FLOAT_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl))))
362362
return FAIL;
363363

364+
/* We at least cannot build -1 for all fixed point types. */
365+
if (FIXED_POINT_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl))))
366+
return FAIL;
367+
364368
if (rhs_class == GIMPLE_UNARY_RHS
365369
&& op0 == *ass_var)
366370
;

0 commit comments

Comments
 (0)