public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "bin.cheng" <bin.cheng@linux.alibaba.com>
To: "GCC Patches" <gcc-patches@gcc.gnu.org>
Subject: 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch
Date: Wed, 14 Jul 2021 17:14:16 +0800	[thread overview]
Message-ID: <b4d9aa23-d36c-4869-818c-c76a3db53392.bin.cheng@linux.alibaba.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

Hi,
I ran into a wrong code bug in code with deep template instantiation when working on sdx::simd.
The root cause as described in commit summary is we skip prologue insns in init_alias_analysis.
This simple patch fixes the issue, however, it's hard to reduce a case because of heavy use of
templates.
Bootstrap and test on x86_64, is it OK?

Thanks,
bin

[-- Attachment #2: 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch --]
[-- Type: application/octet-stream, Size: 1344 bytes --]

Subject: [PATCH 1/2] Don't skip prologue instructions as it could affect alias
 analysis

In init_alias_analysis, we skip prologue instructions but this is
wrong as it could affect base value analysis for registers as well
as following analysis/transformations like cselib and dse:
  prologue:
    x12 = 0x1810
    sp = sp - x12
  ...
    ...
    x12 = SYMBOL_REF(.LC89)
Here reg_base_value[12] is set to ".LC89", however this is only true
after the second instruction setting x12.  The patch fixes the issue
by just handling prologue instructions as normal.  Though ideally it
can be improved in context-sensitive way.

2021-07-14  Bin Cheng  <bin.cheng@linux.alibaba.com>

        * alias.c (init_alias_analysis): Don't skip prologue insns.
---
 gcc/alias.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/alias.c b/gcc/alias.c
index 69e1eb89ac6..9d5eeb082ee 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -3459,8 +3459,9 @@ init_alias_analysis (void)
 		{
 		  rtx note, set;
 
-		  if (could_be_prologue_epilogue
-		      && prologue_epilogue_contains (insn))
+		  /* Don't skip prologue insn because it could change
+		     reg_seen.  */
+		  if (could_be_prologue_epilogue && epilogue_contains (insn))
 		    continue;
 
 		  /* If this insn has a noalias note, process it,  Otherwise,
-- 
2.19.1.6.gb485710b


             reply	other threads:[~2021-07-14  9:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14  9:14 bin.cheng [this message]
2021-07-22  7:01 ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Bin.Cheng
2021-07-22 13:04   ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Richard Biener
2021-07-22 23:36     ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Segher Boessenkool
2021-07-23 16:27     ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Jeff Law
2021-07-26 22:55       ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Segher Boessenkool
2021-07-27 15:20         ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Jeff Law
2021-07-22 23:51 ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Segher Boessenkool
2021-07-23  6:50   ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Bin.Cheng
2021-07-23 16:29 ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Jeff Law
2021-07-26  1:47   ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Bin.Cheng
2021-07-26 15:07     ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Jeff Law
2021-07-27  8:50       ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Bin.Cheng
2021-07-27  8:59         ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Richard Biener
2021-07-27 15:21         ` 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4d9aa23-d36c-4869-818c-c76a3db53392.bin.cheng@linux.alibaba.com \
    --to=bin.cheng@linux.alibaba.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).