diff mbox series

Fix a pasto in lra-remat.c (reg_overlap_for_remat_p)

Message ID 20170901203310.GS2323@tucnak
State New
Headers show
Series Fix a pasto in lra-remat.c (reg_overlap_for_remat_p) | expand

Commit Message

Jakub Jelinek Sept. 1, 2017, 8:33 p.m. UTC
Hi!

This is something that has been reported privately to me.
This is in code introduced in
https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00660.html
and looks indeed like a pasto to me, before the loop there is
a very similar set of stmts without the 2 suffix, and unless
regno being a hard reg (after possible reg_renumber) implies
that regno2 (after possible reg_renumber) is a hard reg, if
unlucky we might access out of bounds.

I don't have a testcase for this, but have bootstrapped/regtested
it on x86_64-linux and i686-linux, ok for trunk?

2017-09-01  Jakub Jelinek  <jakub@redhat.com>

	* lra-remat.c (reg_overlap_for_remat_p): Fix a pasto.


	Jakub

Comments

Richard Biener Sept. 2, 2017, 12:38 p.m. UTC | #1
On September 1, 2017 10:33:10 PM GMT+02:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>This is something that has been reported privately to me.
>This is in code introduced in
>https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00660.html
>and looks indeed like a pasto to me, before the loop there is
>a very similar set of stmts without the 2 suffix, and unless
>regno being a hard reg (after possible reg_renumber) implies
>that regno2 (after possible reg_renumber) is a hard reg, if
>unlucky we might access out of bounds.
>
>I don't have a testcase for this, but have bootstrapped/regtested
>it on x86_64-linux and i686-linux, ok for trunk?

OK. 

Richard. 

>2017-09-01  Jakub Jelinek  <jakub@redhat.com>
>
>	* lra-remat.c (reg_overlap_for_remat_p): Fix a pasto.
>
>--- gcc/lra-remat.c.jj	2017-05-25 10:37:00.000000000 +0200
>+++ gcc/lra-remat.c	2017-09-01 19:42:07.615291583 +0200
>@@ -684,7 +684,7 @@ reg_overlap_for_remat_p (lra_insn_reg *r
> 
> 	if (regno2 >= FIRST_PSEUDO_REGISTER && reg_renumber[regno2] >= 0)
> 	  regno2 = reg_renumber[regno2];
>-	if (regno >= FIRST_PSEUDO_REGISTER)
>+	if (regno2 >= FIRST_PSEUDO_REGISTER)
> 	  nregs2 = 1;
> 	else
> 	  nregs2 = hard_regno_nregs[regno2][reg->biggest_mode];
>
>	Jakub
diff mbox series

Patch

--- gcc/lra-remat.c.jj	2017-05-25 10:37:00.000000000 +0200
+++ gcc/lra-remat.c	2017-09-01 19:42:07.615291583 +0200
@@ -684,7 +684,7 @@  reg_overlap_for_remat_p (lra_insn_reg *r
 
 	if (regno2 >= FIRST_PSEUDO_REGISTER && reg_renumber[regno2] >= 0)
 	  regno2 = reg_renumber[regno2];
-	if (regno >= FIRST_PSEUDO_REGISTER)
+	if (regno2 >= FIRST_PSEUDO_REGISTER)
 	  nregs2 = 1;
 	else
 	  nregs2 = hard_regno_nregs[regno2][reg->biggest_mode];