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

