This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use fld b; fld a; instead of fld a; fld b; fxch %st(1) in reg-stack (PR target/70465)


On 01/25/2017 03:01 PM, Jakub Jelinek wrote:
On Wed, Jan 25, 2017 at 02:43:34PM -0700, Jeff Law wrote:
2017-01-25  Jakub Jelinek  <jakub@redhat.com>

	PR target/70465
	* reg-stack.c (emit_swap_insn): Instead of fld a; fld b; fxchg %st(1);
	emit fld b; fld a; if possible.

	* gcc.target/i386/pr70465.c: New test.
So please comment on the general approach you're taking here.  I have a
pretty good sense of what you're doing, mostly because I pondered something
similar.  But I doubt others coming across the code would see the overall
structure as quickly.

Does the following updated patch explain it sufficiently?

+	  if (i2 != NULL_RTX
+	      && (i2set = single_set (i2)) != NULL_RTX)
+	    {
+	      /* Instead of fld a; fld b; fxch %st(1); just
+		 use fld b; fld a; if possible.  */
+	      rtx i2dest = *get_true_reg (&SET_DEST (i2set));
+	      if (REG_P (i2dest)
+		  && REGNO (i2dest) == FIRST_STACK_REG
+		  && MEM_P (SET_SRC (i2set))
+		  && !side_effects_p (SET_SRC (i2set))
+		  && !modified_between_p (SET_SRC (i1set), i2, i1))
And here we're trying to verify that the insn found above (I2) is pushing
another value onto the FP register stack and that the value in I2 is not
modified between I1 and I2.

No, that last call (as I've tried to explain in the new comment) wants
to ensure that there are no stores in between i2 and i1 that might
alias with the second load's memory (then it would be invalid to move it
before i2) and that the address of the memory doesn't depend on something
set after i2.

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

	PR target/70465
	* reg-stack.c (emit_swap_insn): Instead of fld a; fld b; fxchg %st(1);
	emit fld b; fld a; if possible.

	* gcc.target/i386/pr70465.c: New test.
Yes. Thanks for the comments.  Ok for the trunk.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]