Skip to content

Commit f19ceb2

Browse files
committed
LoongArch: Fix infinite secondary reloading of FCCmode [PR113148]
The GCC internal doc says: X might be a pseudo-register or a 'subreg' of a pseudo-register, which could either be in a hard register or in memory. Use 'true_regnum' to find out; it will return -1 if the pseudo is in memory and the hard register number if it is in a register. So "MEM_P (x)" is not enough for checking if we are reloading from/to the memory. This bug has caused reload pass to stall and finally ICE complaining with "maximum number of generated reload insns per insn achieved", since r14-6814. Check if "true_regnum (x)" is -1 besides "MEM_P (x)" to fix the issue. gcc/ChangeLog: PR target/113148 * config/loongarch/loongarch.cc (loongarch_secondary_reload): Check if regno == -1 besides MEM_P (x) for reloading FCCmode from/to FPR to/from memory. gcc/testsuite/ChangeLog: PR target/113148 * gcc.target/loongarch/pr113148.c: New test.
1 parent 80b8f1e commit f19ceb2

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

gcc/config/loongarch/loongarch.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6906,7 +6906,8 @@ loongarch_secondary_reload (bool in_p ATTRIBUTE_UNUSED, rtx x,
69066906
return NO_REGS;
69076907
}
69086908

6909-
if (reg_class_subset_p (rclass, FP_REGS) && MEM_P (x))
6909+
if (reg_class_subset_p (rclass, FP_REGS)
6910+
&& (regno == -1 || MEM_P (x)))
69106911
return GR_REGS;
69116912

69126913
return NO_REGS;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* PR 113148: ICE caused by infinite reloading */
2+
/* { dg-do compile } */
3+
/* { dg-options "-O2 -march=la464 -mfpu=64 -mabi=lp64d" } */
4+
5+
struct bound
6+
{
7+
double max;
8+
} drawQuadrant_bound;
9+
double w4, innerXfromXY_y, computeBound_right_0;
10+
struct arc_def
11+
{
12+
double w, h;
13+
double a0, a1;
14+
};
15+
static void drawQuadrant (struct arc_def *);
16+
static void
17+
computeBound (struct arc_def *def, struct bound *bound)
18+
{
19+
double ellipsex_1, ellipsex_0;
20+
bound->max = def->a1 ?: __builtin_sin (w4) * def->h;
21+
if (def->a0 == 5 && def->w == def->h)
22+
;
23+
else
24+
ellipsex_0 = def->a0 == 0.0 ?: __builtin_cos (w4);
25+
if (def->a1 == 5 && def->w == def->h)
26+
ellipsex_1 = bound->max;
27+
__builtin_sqrt (ellipsex_1 * innerXfromXY_y * innerXfromXY_y * w4);
28+
computeBound_right_0 = ellipsex_0;
29+
}
30+
void
31+
drawArc ()
32+
{
33+
struct arc_def foo;
34+
for (;;)
35+
drawQuadrant (&foo);
36+
}
37+
void
38+
drawQuadrant (struct arc_def *def)
39+
{
40+
int y, miny;
41+
computeBound (def, &drawQuadrant_bound);
42+
while (y >= miny)
43+
;
44+
}

0 commit comments

Comments
 (0)