diff mbox series

combine: Fix various shortcomings in make_more_copies (PR87701, PR87780)

Message ID aebb76ab9573c5f10b8ca356bfaab419446462bf.1540797565.git.segher@kernel.crashing.org
State New
Headers show
Series combine: Fix various shortcomings in make_more_copies (PR87701, PR87780) | expand

Commit Message

Segher Boessenkool Oct. 29, 2018, 7:28 a.m. UTC
This rewrites most of make_more_copies, in the process fixing a few PRs
and some other bugs, and working around a few target problems.  Certain
notes turn out to actually change the meaning of the RTL, so we cannot
drop them; and i386 takes subregs of hard regs.

Committing.


Segher


2018-10-29  Segher Boessenkool  <segher@kernel.crashing.org>

	PR rtl-optimization/87701
	PR rtl-optimization/87780
	* combine.c (make_more_copies): Rewrite.

---
 gcc/combine.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Andrew Pinski Oct. 29, 2018, 7:31 a.m. UTC | #1
On Mon, Oct 29, 2018 at 12:29 AM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> This rewrites most of make_more_copies, in the process fixing a few PRs
> and some other bugs, and working around a few target problems.  Certain
> notes turn out to actually change the meaning of the RTL, so we cannot
> drop them; and i386 takes subregs of hard regs.
>
> Committing.
Only one comment about the changelog.

>
>
> Segher
>
>
> 2018-10-29  Segher Boessenkool  <segher@kernel.crashing.org>
>
>         PR rtl-optimization/87701
>         PR rtl-optimization/87780
>         * combine.c (make_more_copies): Rewrite.

I think a better changelog would be :):
* combine.c (make_more_copies): Rewrite to be simplier.

Thanks,
Andrew

>
> ---
>  gcc/combine.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/gcc/combine.c b/gcc/combine.c
> index bd593bdc..dfb0b44 100644
> --- a/gcc/combine.c
> +++ b/gcc/combine.c
> @@ -14990,25 +14990,20 @@ make_more_copies (void)
>           rtx set = single_set (insn);
>           if (!set)
>             continue;
> -         rtx src = SET_SRC (set);
>           rtx dest = SET_DEST (set);
>           if (dest == pc_rtx)
>             continue;
> -         if (GET_CODE (src) == SUBREG)
> -           src = SUBREG_REG (src);
> +         rtx src = SET_SRC (set);
>           if (!(REG_P (src) && HARD_REGISTER_P (src)))
>             continue;
>           if (TEST_HARD_REG_BIT (fixed_reg_set, REGNO (src)))
>             continue;
>
>           rtx new_reg = gen_reg_rtx (GET_MODE (dest));
> -         rtx_insn *insn1 = gen_move_insn (new_reg, src);
> -         rtx_insn *insn2 = gen_move_insn (dest, new_reg);
> -         emit_insn_after (insn1, insn);
> -         emit_insn_after (insn2, insn1);
> -         delete_insn (insn);
> -
> -         insn = insn2;
> +         rtx_insn *new_insn = gen_move_insn (new_reg, src);
> +         SET_SRC (set) = new_reg;
> +         emit_insn_before (new_insn, insn);
> +         df_insn_rescan (insn);
>         }
>      }
>  }
> --
> 1.8.3.1
>
Segher Boessenkool Oct. 29, 2018, 7:49 a.m. UTC | #2
On Mon, Oct 29, 2018 at 12:31:28AM -0700, Andrew Pinski wrote:
> >         PR rtl-optimization/87701
> >         PR rtl-optimization/87780
> >         * combine.c (make_more_copies): Rewrite.
> 
> I think a better changelog would be :):
> * combine.c (make_more_copies): Rewrite to be simplier.

But it is not simpler at all now: *not* removing old notes while changing
RTL instructions is a very bad idea often; and modifying instructions
while not being very careful upsets DF.  It may *look* simple now ;-)


Segher
Jeff Law Oct. 29, 2018, 3:56 p.m. UTC | #3
On 10/29/18 1:49 AM, Segher Boessenkool wrote:
> On Mon, Oct 29, 2018 at 12:31:28AM -0700, Andrew Pinski wrote:
>>>         PR rtl-optimization/87701
>>>         PR rtl-optimization/87780
>>>         * combine.c (make_more_copies): Rewrite.
>>
>> I think a better changelog would be :):
>> * combine.c (make_more_copies): Rewrite to be simplier.
> 
> But it is not simpler at all now: *not* removing old notes while changing
> RTL instructions is a very bad idea often; and modifying instructions
> while not being very careful upsets DF.  It may *look* simple now ;-)
FWIW, it looks like cr16 ran to completion this morning :-)

Jeff
diff mbox series

Patch

diff --git a/gcc/combine.c b/gcc/combine.c
index bd593bdc..dfb0b44 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -14990,25 +14990,20 @@  make_more_copies (void)
 	  rtx set = single_set (insn);
 	  if (!set)
 	    continue;
-	  rtx src = SET_SRC (set);
 	  rtx dest = SET_DEST (set);
 	  if (dest == pc_rtx)
 	    continue;
-	  if (GET_CODE (src) == SUBREG)
-	    src = SUBREG_REG (src);
+	  rtx src = SET_SRC (set);
 	  if (!(REG_P (src) && HARD_REGISTER_P (src)))
 	    continue;
 	  if (TEST_HARD_REG_BIT (fixed_reg_set, REGNO (src)))
 	    continue;
 
 	  rtx new_reg = gen_reg_rtx (GET_MODE (dest));
-	  rtx_insn *insn1 = gen_move_insn (new_reg, src);
-	  rtx_insn *insn2 = gen_move_insn (dest, new_reg);
-	  emit_insn_after (insn1, insn);
-	  emit_insn_after (insn2, insn1);
-	  delete_insn (insn);
-
-	  insn = insn2;
+	  rtx_insn *new_insn = gen_move_insn (new_reg, src);
+	  SET_SRC (set) = new_reg;
+	  emit_insn_before (new_insn, insn);
+	  df_insn_rescan (insn);
 	}
     }
 }