diff mbox

combine: More distribute_notes trouble (PR69737)

Message ID 7c9ac3d29a29c4b1bc78294afb955f30fd36ad77.1455137361.git.segher@kernel.crashing.org
State New
Headers show

Commit Message

Segher Boessenkool Feb. 11, 2016, 5:04 p.m. UTC
PR64682 is a problem in distribute_notes, where it has trouble putting
a REG_DEAD note for a reg that is set twice in the right spot.  My fix
for that did the wrong thing for PR69567.  And then my attempted fix
for that one made PR64682 fail again.

Instead, let's just lose the note in such complicated cases, like we
already do in certain similar cases.

Tested on powerpc64-linux and x86_64-linux.  Also built Linux kernels
for some 30 supported targets; no difference in generated code was
observed.

Committing to trunk.

HJ, I tested this on GCC 5 for x86_64-linux, the failure is gone;
could you test it on your setup before I apply it there though?


Segher


2016-02-11  Segher Boessenkool  <segher@kernel.crashing.org>

	PR rtl-optimization/64682
	PR rtl-optimization/69567
	PR rtl-optimization/69737
	* combine.c (distribute_notes) <REG_DEAD>: If the register is set
	in I2 as well, just lose it.

---
 gcc/combine.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

Comments

H.J. Lu Feb. 11, 2016, 8:54 p.m. UTC | #1
On Thu, Feb 11, 2016 at 9:04 AM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> PR64682 is a problem in distribute_notes, where it has trouble putting
> a REG_DEAD note for a reg that is set twice in the right spot.  My fix
> for that did the wrong thing for PR69567.  And then my attempted fix
> for that one made PR64682 fail again.
>
> Instead, let's just lose the note in such complicated cases, like we
> already do in certain similar cases.
>
> Tested on powerpc64-linux and x86_64-linux.  Also built Linux kernels
> for some 30 supported targets; no difference in generated code was
> observed.
>
> Committing to trunk.
>
> HJ, I tested this on GCC 5 for x86_64-linux, the failure is gone;
> could you test it on your setup before I apply it there though?
>
>
> Segher
>
>
> 2016-02-11  Segher Boessenkool  <segher@kernel.crashing.org>
>
>         PR rtl-optimization/64682
>         PR rtl-optimization/69567
>         PR rtl-optimization/69737
>         * combine.c (distribute_notes) <REG_DEAD>: If the register is set
>         in I2 as well, just lose it.
>
>

Yes, it fixed the regressions on ia32 and x96-64:

New passes:
FAIL: gcc.c-torture/execute/pr64682.c   -O2  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O2  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O2 -flto
-fno-use-linker-plugin -flto-partition=none  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O3 -fomit-frame-pointer  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O3 -fomit-frame-pointer  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O3 -fomit-frame-pointer
-funroll-all-loops -finline-functions  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O3 -fomit-frame-pointer
-funroll-all-loops -finline-functions  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O3 -fomit-frame-pointer
-funroll-loops  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O3 -fomit-frame-pointer
-funroll-loops  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O3 -g  execution test
FAIL: gcc.c-torture/execute/pr64682.c   -O3 -g  execution test

Thanks.
diff mbox

Patch

diff --git a/gcc/combine.c b/gcc/combine.c
index 3609b94..24dcefa 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -13901,7 +13901,6 @@  distribute_notes (rtx notes, rtx_insn *from_insn, rtx_insn *i3, rtx_insn *i2,
 	    tem_insn = from_insn;
 	  else
 	    {
-	      tem_insn = i3;
 	      if (from_insn
 		  && CALL_P (from_insn)
 		  && find_reg_fusage (from_insn, USE, XEXP (note, 0)))
@@ -13910,14 +13909,7 @@  distribute_notes (rtx notes, rtx_insn *from_insn, rtx_insn *i3, rtx_insn *i2,
 		place = i3;
 	      else if (i2 != 0 && next_nonnote_nondebug_insn (i2) == i3
 		       && reg_referenced_p (XEXP (note, 0), PATTERN (i2)))
-		{
-		  place = i2;
-		  /* If the new I2 sets the same register that is marked dead
-		     in the note, the note now should not be put on I2, as the
-		     note refers to a previous incarnation of the reg.  */
-		  if (reg_set_p (XEXP (note, 0), PATTERN (i2)))
-		    tem_insn = i2;
-		}
+		place = i2;
 	      else if ((rtx_equal_p (XEXP (note, 0), elim_i2)
 			&& !(i2mod
 			     && reg_overlap_mentioned_p (XEXP (note, 0),
@@ -13925,6 +13917,12 @@  distribute_notes (rtx notes, rtx_insn *from_insn, rtx_insn *i3, rtx_insn *i2,
 		       || rtx_equal_p (XEXP (note, 0), elim_i1)
 		       || rtx_equal_p (XEXP (note, 0), elim_i0))
 		break;
+	      tem_insn = i3;
+	      /* If the new I2 sets the same register that is marked dead
+		 in the note, we do not know where to put the note.
+		 Give up.  */
+	      if (i2 != 0 && reg_set_p (XEXP (note, 0), PATTERN (i2)))
+		break;
 	    }
 
 	  if (place == 0)