* [PATCH] regrename: Fix -fcompare-debug issue in check_new_reg_p [PR105041]
@ 2022-06-10 14:22 Surya Kumari Jangala
2022-06-10 15:40 ` Segher Boessenkool
0 siblings, 1 reply; 3+ messages in thread
From: Surya Kumari Jangala @ 2022-06-10 14:22 UTC (permalink / raw)
To: gcc-patches, bergner, segher
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 <jskumari@linux.ibm.com>
gcc/
PR rtl-optimization/105041
* regrename.cc (check_new_reg_p): Use nregs value from du chain.
gcc/testsuite/
PR rtl-optimization/105041
* gcc.target/powerpc/pr105041.c: New test.
diff --git a/gcc/regrename.cc b/gcc/regrename.cc
index 10271e1..f651351 100644
--- a/gcc/regrename.cc
+++ b/gcc/regrename.cc
@@ -324,8 +324,7 @@ static bool
check_new_reg_p (int reg ATTRIBUTE_UNUSED, int new_reg,
class du_head *this_head, HARD_REG_SET this_unavailable)
{
- machine_mode mode = GET_MODE (*this_head->first->loc);
- int nregs = hard_regno_nregs (new_reg, mode);
+ int nregs = this_head->nregs;
int i;
struct du_chain *tmp;
diff --git a/gcc/testsuite/gcc.target/powerpc/pr105041.c b/gcc/testsuite/gcc.target/powerpc/pr105041.c
new file mode 100644
index 0000000..89eed1c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr105041.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target be } */
+/* { dg-options "-m32 -mdejagnu-cpu=power4 -O2 -fcompare-debug -fharden-compares -frename-registers" } */
+
+double m;
+int n;
+
+unsigned int
+foo (unsigned int x, int y)
+{
+ long long int a = y, b = !a;
+ int c = 0;
+
+ if (b != x)
+ while ((int) m == a)
+ {
+ c = a;
+ a = 0;
+ }
+
+ n = b = y;
+
+ return x + c;
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regrename: Fix -fcompare-debug issue in check_new_reg_p [PR105041]
2022-06-10 14:22 [PATCH] regrename: Fix -fcompare-debug issue in check_new_reg_p [PR105041] Surya Kumari Jangala
@ 2022-06-10 15:40 ` Segher Boessenkool
2022-06-10 20:09 ` Jeff Law
0 siblings, 1 reply; 3+ messages in thread
From: Segher Boessenkool @ 2022-06-10 15:40 UTC (permalink / raw)
To: Surya Kumari Jangala; +Cc: gcc-patches, bergner
Hi!
On Fri, Jun 10, 2022 at 07:52:57PM +0530, Surya Kumari Jangala wrote:
> 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.
Great, thanks for finding and fixing this! I cannot approve it, you'll
have to wait for someone who can. It looks fine to me, but that does
not mean so much in regrename.c :-)
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/pr105041.c
> @@ -0,0 +1,24 @@
> +/* { dg-do compile } */
Please delete this line, it is the default.
> +/* { dg-require-effective-target be } */
Is there a reason to not test this on LE? If not, please remove this
line as well.
> +/* { dg-options "-m32 -mdejagnu-cpu=power4 -O2 -fcompare-debug -fharden-compares -frename-registers" } */
Aha. You check for LE because you use -m32 in the test? Don't, then!
Instead, test with -m32 in your RUNTESTFLAGS, like
make check-gcc-c RUNTESTFLAGS="--target_board=unix'{-m64,-m32}' powerpc.exp=pr105041.c"
or similar.
It's a good idea to add a comment a la
/* PR rtl-optimization/105041: This test failed with -m32. */
Thanks again for the patch!
Segher
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regrename: Fix -fcompare-debug issue in check_new_reg_p [PR105041]
2022-06-10 15:40 ` Segher Boessenkool
@ 2022-06-10 20:09 ` Jeff Law
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Law @ 2022-06-10 20:09 UTC (permalink / raw)
To: gcc-patches
On 6/10/2022 9:40 AM, Segher Boessenkool wrote:
> Hi!
>
> On Fri, Jun 10, 2022 at 07:52:57PM +0530, Surya Kumari Jangala wrote:
>> 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.
> Great, thanks for finding and fixing this! I cannot approve it, you'll
> have to wait for someone who can. It looks fine to me, but that does
> not mean so much in regrename.c :-)
I'll go ahead and ACK the regrename bits. So as soon as you're happy
with the testsuite bits, this is good to go.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-10 20:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10 14:22 [PATCH] regrename: Fix -fcompare-debug issue in check_new_reg_p [PR105041] Surya Kumari Jangala
2022-06-10 15:40 ` Segher Boessenkool
2022-06-10 20:09 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).