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] Fix DCE REG_LIBCALL note moving from noop move insns (PR rtl-optimization/33644)


On Fri, Oct 19, 2007 at 11:54:52AM -0400, Jakub Jelinek wrote:
> Anyway, just tried (sorry for the delay) removing the libcall stuff, just
> generate:
> (call_insn/u 5 4 6 mm2.c:4 (parallel [
>             (set (reg:DI 0 ax)
>                 (call:DI (mem:QI (symbol_ref:DI ("__tls_get_addr")) [0 S1 A8])
>                     (const_int 0 [0x0])))
>             (unspec:DI [
>                     (const_int 0 [0x0])
>                 ] 20)
>         ]) -1 (nil)
>     (nil))
> 
> (insn 6 5 7 mm2.c:4 (set (reg:DI 60)
>         (reg:DI 0 ax)) -1 (nil))
> 
> but CSE isn't able to merge these.  Will still try to add REG_EQUAL note to
> the pseudo = %rax insn if that helps.

Adding REG_EQUAL note was all that was needed for CSEing it, but dce.c still
won't delete it, because it punts on all UNSPECs.  The UNSPECs are really
necessary for the __tls_get_addr call, as the call_insn has mandatory insn
sequence that needs to be output there (to make TLS transitions possible).
The comment says:
      /* The UNSPEC case was added here because the ia-64 claims that
         USEs do not work after reload and generates UNSPECS rather
         than USEs.  Since dce is run after reload we need to avoid
         deleting these even if they are dead.  If it turns out that
         USEs really do work after reload, the ia-64 should be
         changed, and the UNSPEC case can be removed.  */
I wonder what kind of UNSPECs and at what places were the reasons to add it,
I very much doubt not dceing any UNSPECs is desirable, even on ia64.
Say speculative moves use UNSPEC_LDS{,A}, but they certainly should be dced.

--- gcc/config/i386/i386.c.jj	2007-10-19 14:39:55.000000000 +0200
+++ gcc/config/i386/i386.c	2007-10-19 18:05:57.000000000 +0200
@@ -7644,7 +7644,7 @@ legitimize_tls_address (rtx x, enum tls_
 
       if (TARGET_64BIT && ! TARGET_GNU2_TLS)
 	{
-	  rtx rax = gen_rtx_REG (Pmode, AX_REG), insns;
+	  rtx rax = gen_rtx_REG (Pmode, AX_REG), insns, last;
 
 	  start_sequence ();
 	  emit_call_insn (gen_tls_global_dynamic_64 (rax, x));
@@ -7652,7 +7652,10 @@ legitimize_tls_address (rtx x, enum tls_
 	  end_sequence ();
 
 	  CONST_OR_PURE_CALL_P (insns) = 1;
-	  emit_libcall_block (insns, dest, rax, x);
+/*	  emit_libcall_block (insns, dest, rax, x); */
+	  emit_insn (insns);
+	  emit_move_insn (dest, rax);
+	  last = set_unique_reg_note (last, REG_EQUAL, x);
 	}
       else if (TARGET_64BIT && TARGET_GNU2_TLS)
 	emit_insn (gen_tls_global_dynamic_64 (dest, x));
@@ -7673,7 +7676,7 @@ legitimize_tls_address (rtx x, enum tls_
 
       if (TARGET_64BIT && ! TARGET_GNU2_TLS)
 	{
-	  rtx rax = gen_rtx_REG (Pmode, AX_REG), insns, note;
+	  rtx rax = gen_rtx_REG (Pmode, AX_REG), insns, note, last;
 
 	  start_sequence ();
 	  emit_call_insn (gen_tls_local_dynamic_base_64 (rax));
@@ -7683,7 +7686,10 @@ legitimize_tls_address (rtx x, enum tls_
 	  note = gen_rtx_EXPR_LIST (VOIDmode, const0_rtx, NULL);
 	  note = gen_rtx_EXPR_LIST (VOIDmode, ix86_tls_get_addr (), note);
 	  CONST_OR_PURE_CALL_P (insns) = 1;
-	  emit_libcall_block (insns, base, rax, note);
+/*	  emit_libcall_block (insns, base, rax, note); */
+	  emit_insn (insns);
+	  last = emit_move_insn (base, rax);
+	  set_unique_reg_note (last, REG_EQUAL, note);
 	}
       else if (TARGET_64BIT && TARGET_GNU2_TLS)
 	emit_insn (gen_tls_local_dynamic_base_64 (base));
--- gcc/dce.c.jj	2007-10-19 14:39:55.000000000 +0200
+++ gcc/dce.c	2007-10-19 18:01:08.000000000 +0200
@@ -102,7 +102,8 @@ deletable_insn_p (rtx insn, bool fast)
   rtx body, x;
   int i;
 
-  if (!NONJUMP_INSN_P (insn))
+  if (!NONJUMP_INSN_P (insn)
+      && (!CALL_P (insn) || !CONST_OR_PURE_CALL_P (insn)))
     return false;
 
   body = PATTERN (insn);


	Jakub


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