fwprop: Rewrite to use RTL SSA

This patch rewrites fwprop.c to use the RTL SSA framework.  It tries
as far as possible to mimic the old behaviour, even in caes where
that doesn't fit naturally with the new framework.  I've added ???
comments to mark those places, but I think “fixing” them should
be done separately to make bisection easier.

In particular:

* The old implementation iterated over uses, and after a successful
  substitution, the new insn's uses were added to the end of the list.
  The pass still processed those uses, but because it processed them at
  the end, it didn't fully optimise one instruction before propagating
  it into the next.

  The new version follows the same approach for comparison purposes,
  but I'd like to drop that as a follow-on patch.

* The old implementation operated on single use sites (DF_REF_LOCs).
  This doesn't work well for instructions with match_dups, where it's
  necessary to update both an operand and its dups at the same time.
  For example, attempting to substitute into a divmod instruction would
  fail because only the div or the mod side would be updated.

  The new version again follows this to some extent for comparison
  purposes (although not exactly).  Again I'd like to drop it as a
  follow-on patch.

  One difference is that if a register occurs in multiple MEM addresses
  in a set, the new version will try to update them all at once.  This is
  what causes the SVE ACLE st4* output to improve.

Also, the old version didn't naturally guarantee termination (PR79405),
whereas the new one does.

gcc/
	* fwprop.c: Rewrite to use the RTL SSA framework.

gcc/testsuite/
	* gcc.dg/rtl/x86_64/test-return-const.c.before-fwprop.c: Don't
	expect insn updates to be deferred.
	* gcc.target/aarch64/sve/acle/asm/st4_s8.c: Expect the addition
	to be folded into the address.
	* gcc.target/aarch64/sve/acle/asm/st4_u8.c: Likewise.
This commit is contained in:
Richard Sandiford 2020-12-17 00:15:12 +00:00
parent 73b7582775
commit 0b76990a9d
4 changed files with 595 additions and 1202 deletions

File diff suppressed because it is too large Load diff

View file

@ -31,7 +31,7 @@ int __RTL (startwith ("fwprop1")) test_returning_constant (void)
}
/* Verify that insn 5 is eliminated. */
/* { dg-final { scan-rtl-dump "deferring deletion of insn with uid = 5" "fwprop1" } } */
/* { dg-final { scan-rtl-dump "deleting insn with uid = 5" "fwprop1" } } */
/* { dg-final { scan-rtl-dump "Deleted 1 trivially dead insns" "fwprop1" } } */
int main (void)

View file

@ -74,7 +74,7 @@ TEST_STORE (st4_s8_28, svint8x4_t, int8_t,
/*
** st4_s8_32:
** [^{]*
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+\]
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+, x[0-9]+\]
** ret
*/
TEST_STORE (st4_s8_32, svint8x4_t, int8_t,
@ -135,7 +135,7 @@ TEST_STORE (st4_s8_m32, svint8x4_t, int8_t,
/*
** st4_s8_m36:
** [^{]*
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+\]
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+, x[0-9]+\]
** ret
*/
TEST_STORE (st4_s8_m36, svint8x4_t, int8_t,
@ -205,7 +205,7 @@ TEST_STORE (st4_vnum_s8_28, svint8x4_t, int8_t,
/*
** st4_vnum_s8_32:
** [^{]*
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+\]
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+, x[0-9]+\]
** ret
*/
TEST_STORE (st4_vnum_s8_32, svint8x4_t, int8_t,
@ -266,7 +266,7 @@ TEST_STORE (st4_vnum_s8_m32, svint8x4_t, int8_t,
/*
** st4_vnum_s8_m36:
** [^{]*
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+\]
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+, x[0-9]+\]
** ret
*/
TEST_STORE (st4_vnum_s8_m36, svint8x4_t, int8_t,

View file

@ -74,7 +74,7 @@ TEST_STORE (st4_u8_28, svuint8x4_t, uint8_t,
/*
** st4_u8_32:
** [^{]*
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+\]
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+, x[0-9]+\]
** ret
*/
TEST_STORE (st4_u8_32, svuint8x4_t, uint8_t,
@ -135,7 +135,7 @@ TEST_STORE (st4_u8_m32, svuint8x4_t, uint8_t,
/*
** st4_u8_m36:
** [^{]*
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+\]
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+, x[0-9]+\]
** ret
*/
TEST_STORE (st4_u8_m36, svuint8x4_t, uint8_t,
@ -205,7 +205,7 @@ TEST_STORE (st4_vnum_u8_28, svuint8x4_t, uint8_t,
/*
** st4_vnum_u8_32:
** [^{]*
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+\]
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+, x[0-9]+\]
** ret
*/
TEST_STORE (st4_vnum_u8_32, svuint8x4_t, uint8_t,
@ -266,7 +266,7 @@ TEST_STORE (st4_vnum_u8_m32, svuint8x4_t, uint8_t,
/*
** st4_vnum_u8_m36:
** [^{]*
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+\]
** st4b {z0\.b - z3\.b}, p0, \[x[0-9]+, x[0-9]+\]
** ret
*/
TEST_STORE (st4_vnum_u8_m36, svuint8x4_t, uint8_t,