From f94302e90b09bc30d5ba357d4f84aa37f7a75ad1 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 21 Apr 2019 18:23:00 +0000 Subject: [PATCH] LRA: Revert "Remove useless move insns" Useless move insn removal was added to LRA just to avoid wasting CPU cycles on such insn processing afterwards. Such insns are removed anyway later in the pass pipeline. The CPU time savings are tiny but the removal creates too many problems including PR target/90178. Vladimir pre-approved the patch to remove the code: https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00834.html gcc/ PR target/90178 Revert: 2018-11-21 Uros Bizjak Revert the revert: 2013-10-26 Vladimir Makarov Revert: 2013-10-25 Vladimir Makarov * lra-spills.c (lra_final_code_change): Remove useless move insns. gcc/testsuite/ PR target/90178 * gcc.target/i386/pr90178.c: New test. From-SVN: r270484 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/lra-spills.c | 15 --------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr90178.c | 13 +++++++++++++ 4 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr90178.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8b09eecfbfe..d2446815605 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2019-04-21 H.J. Lu + + PR target/90178 + Revert: + 2018-11-21 Uros Bizjak + + Revert the revert: + 2013-10-26 Vladimir Makarov + + Revert: + 2013-10-25 Vladimir Makarov + + * lra-spills.c (lra_final_code_change): Remove useless move insns. + 2019-04-21 Iain Sandoe * config/rs6000/rs6000.md (group_end_nop): Emit insn register diff --git a/gcc/lra-spills.c b/gcc/lra-spills.c index c19b76a579c..18db79e70a0 100644 --- a/gcc/lra-spills.c +++ b/gcc/lra-spills.c @@ -740,7 +740,6 @@ lra_final_code_change (void) int i, hard_regno; basic_block bb; rtx_insn *insn, *curr; - rtx set; int max_regno = max_reg_num (); for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) @@ -819,19 +818,5 @@ lra_final_code_change (void) } if (insn_change_p) lra_update_operator_dups (id); - - if ((set = single_set (insn)) != NULL - && REG_P (SET_SRC (set)) && REG_P (SET_DEST (set)) - && REGNO (SET_SRC (set)) == REGNO (SET_DEST (set))) - { - /* Remove an useless move insn. IRA can generate move - insns involving pseudos. It is better remove them - earlier to speed up compiler a bit. It is also - better to do it here as they might not pass final RTL - check in LRA, (e.g. insn moving a control register - into itself). */ - lra_invalidate_insn_data (insn); - delete_insn (insn); - } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ee1281e6cab..983382492f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-04-21 H.J. Lu + + PR target/90178 + * gcc.target/i386/pr90178.c: New test. + 2019-04-20 Sandra Loosemore * g++.dg/ipa/pr89009.C: Add dg-require-effective-target fpic. diff --git a/gcc/testsuite/gcc.target/i386/pr90178.c b/gcc/testsuite/gcc.target/i386/pr90178.c new file mode 100644 index 00000000000..1df36af0541 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr90178.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx -mvzeroupper" } */ + +int* +find_ptr (int* mem, int sz, int val) +{ + for (int i = 0; i < sz; i++) + if (mem[i] == val) + return &mem[i]; + return 0; +} + +/* { dg-final { scan-assembler-times "xorl\[\\t \]*\\\%eax,\[\\t \]*%eax" 1 } } */ -- 2.30.2