From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7875) id 194B43858D28; Thu, 21 Jul 2022 06:38:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 194B43858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Surya Kumari Jangala To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-10156] regrename: Fix -fcompare-debug issue in check_new_reg_p [PR105041] X-Act-Checkin: gcc X-Git-Author: Surya Kumari Jangala X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 7a00dfb353675b80e6a10d815204b1fe576f098a X-Git-Newrev: 8522fab3f900d6fe0cc43be52fdd850f5c9c44db Message-Id: <20220721063815.194B43858D28@sourceware.org> Date: Thu, 21 Jul 2022 06:38:15 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2022 06:38:15 -0000 https://gcc.gnu.org/g:8522fab3f900d6fe0cc43be52fdd850f5c9c44db commit r11-10156-g8522fab3f900d6fe0cc43be52fdd850f5c9c44db Author: Surya Kumari Jangala Date: Fri Jun 10 19:52:57 2022 +0530 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 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 3e16b4359e86b36676ed01219e6deafa95f3c16b) Diff: --- gcc/regrename.c | 3 +-- gcc/testsuite/gcc.target/powerpc/pr105041.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gcc/regrename.c b/gcc/regrename.c index c0d4643f802..0cf93d323d9 100644 --- a/gcc/regrename.c +++ b/gcc/regrename.c @@ -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 00000000000..c52b7a5ef30 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr105041.c @@ -0,0 +1,22 @@ +/* { dg-options "-mdejagnu-cpu=power4 -O2 -fcompare-debug -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; +}