Skip to content

Commit 8522fab

Browse files
Surya Kumari JangalaSurya Kumari Jangala
authored andcommitted
regrename: Fix -fcompare-debug issue in check_new_reg_p [PR105041]
In check_new_reg_p, the nregs of a du chain is computed by obtaining the MODE of the first element in the chain, and then calling hard_regno_nregs() with the MODE. But the first element of the chain can be a DEBUG_INSN whose mode need not be the same as the rest of the elements in the du chain. This was resulting in fcompare-debug failure as check_new_reg_p was returning a different result with -g for the same candidate register. We can instead obtain nregs from the du chain itself. 2022-06-10 Surya Kumari Jangala <[email protected]> gcc/ PR rtl-optimization/105041 * regrename.c (check_new_reg_p): Use nregs value from du chain. gcc/testsuite/ PR rtl-optimization/105041 * gcc.target/powerpc/pr105041.c: New test. (cherry picked from commit 3e16b43)
1 parent 7a00dfb commit 8522fab

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

gcc/regrename.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ static bool
324324
check_new_reg_p (int reg ATTRIBUTE_UNUSED, int new_reg,
325325
class du_head *this_head, HARD_REG_SET this_unavailable)
326326
{
327-
machine_mode mode = GET_MODE (*this_head->first->loc);
328-
int nregs = hard_regno_nregs (new_reg, mode);
327+
int nregs = this_head->nregs;
329328
int i;
330329
struct du_chain *tmp;
331330

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* { dg-options "-mdejagnu-cpu=power4 -O2 -fcompare-debug -frename-registers" } */
2+
3+
double m;
4+
int n;
5+
6+
unsigned int
7+
foo (unsigned int x, int y)
8+
{
9+
long long int a = y, b = !a;
10+
int c = 0;
11+
12+
if (b != x)
13+
while ((int) m == a)
14+
{
15+
c = a;
16+
a = 0;
17+
}
18+
19+
n = b = y;
20+
21+
return x + c;
22+
}

0 commit comments

Comments
 (0)