public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH][ PR rtl-optimization/79286] Drop may_trap_p exception to testing dominance in update_equiv_regs
@ 2017-04-23 18:33 Bernd Edlinger
  2017-04-28 17:17 ` Jeff Law
  0 siblings, 1 reply; 12+ messages in thread
From: Bernd Edlinger @ 2017-04-23 18:33 UTC (permalink / raw)
  To: Jeff Law, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

Hi Jeff,


this patch tries to fix the handling of pic_offset_rtx + 
const(unspec(symbol_ref)+ const_int) in may_trap_p,
and restores the original state of affairs in update_equiv_regs.


What do you think is it OK to extract the symbol_ref out
of the unspec in this way, or is does it need a target hook?


Patch works at least for x86_64 and arm.
Is it OK for trunk?


Bernd.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-pr79286.diff --]
[-- Type: text/x-patch; name="patch-pr79286.diff", Size: 2459 bytes --]

2017-04-23  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        rtl-optimizatoin/79286
        * ira.c (update_equiv_regs): Revert to using may_tap_p again.
        * rtlanal.c (rtx_addr_can_trap_p_1): SYMBOL_REF_FUNCTION_P can never
	trap.  Extract constant offset from pic_offset_table_rtx +
	const(unspec(symbol_ref)+int_val) and pic_offset_table_rtx +
	const(unspec(symbol_ref)), otherwise RTL may trap.

Index: gcc/ira.c
===================================================================
--- gcc/ira.c	(revision 247077)
+++ gcc/ira.c	(working copy)
@@ -3551,7 +3551,8 @@ update_equiv_regs (void)
 	  if (DF_REG_DEF_COUNT (regno) == 1
 	      && note
 	      && !rtx_varies_p (XEXP (note, 0), 0)
-	      && def_dominates_uses (regno))
+	      && (!may_trap_or_fault_p (XEXP (note, 0))
+		  || def_dominates_uses (regno)))
 	    {
 	      rtx note_value = XEXP (note, 0);
 	      remove_note (insn, note);
Index: gcc/rtlanal.c
===================================================================
--- gcc/rtlanal.c	(revision 247077)
+++ gcc/rtlanal.c	(working copy)
@@ -485,7 +485,7 @@ rtx_addr_can_trap_p_1 (const_rtx x, HOST_WIDE_INT
     case SYMBOL_REF:
       if (SYMBOL_REF_WEAK (x))
 	return 1;
-      if (!CONSTANT_POOL_ADDRESS_P (x))
+      if (!CONSTANT_POOL_ADDRESS_P (x) && !SYMBOL_REF_FUNCTION_P (x))
 	{
 	  tree decl;
 	  HOST_WIDE_INT decl_size;
@@ -645,8 +645,23 @@ rtx_addr_can_trap_p_1 (const_rtx x, HOST_WIDE_INT
     case PLUS:
       /* An address is assumed not to trap if:
          - it is the pic register plus a constant.  */
-      if (XEXP (x, 0) == pic_offset_table_rtx && CONSTANT_P (XEXP (x, 1)))
-	return 0;
+      if (XEXP (x, 0) == pic_offset_table_rtx
+	  && GET_CODE (XEXP (x, 1)) == CONST)
+	{
+	  x = XEXP (XEXP (x, 1), 0);
+	  if (GET_CODE (x) == UNSPEC
+	      && GET_CODE (XVECEXP (x, 0, 0)) == SYMBOL_REF)
+	    return rtx_addr_can_trap_p_1(XVECEXP (x, 0, 0),
+					 offset, size, mode, unaligned_mems);
+	  if (GET_CODE (x) == PLUS
+	      && GET_CODE (XEXP (x, 0)) == UNSPEC
+	      && GET_CODE (XVECEXP (XEXP (x, 0), 0, 0)) == SYMBOL_REF
+	      && CONST_INT_P (XEXP (x, 1)))
+	    return rtx_addr_can_trap_p_1(XVECEXP (XEXP (x, 0), 0, 0),
+					 offset + INTVAL (XEXP (x, 1)),
+					 size, mode, unaligned_mems);
+	  return 1;
+	}
 
       /* - or it is an address that can't trap plus a constant integer.  */
       if (CONST_INT_P (XEXP (x, 1))

^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH][ PR rtl-optimization/79286] Drop may_trap_p exception to testing dominance in update_equiv_regs
@ 2017-02-24 15:48 Jeff Law
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff Law @ 2017-02-24 15:48 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]


Per a discussion with Alan...

update_equiv_regs now tests that the insn which creates an equivalence 
dominates its uses.  With one exception, if may_trap_p returns false, we 
don't require dominance.

may_trap_p unfortunately returns false for PIC references in cases where 
they can clearly trap (as seen with the reduced testcase for this BZ in 
PIC mode).  I'm not really up for pulling on that thread right now.

Instead we just drop the may_trap_p exception and always verify 
dominance.  This fixes 79286 when generating PIC (and thus ought to fix 
the i686 darwin issues.

Bootstrapped and regression tested on i686-pc-linux-gnu.  Also hand 
verified the reduced testcase works with PIC.

Installing on the trunk.

Jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 1162 bytes --]

commit 3a05b44836c9576b33101ed7c381ad21aa5f1581
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Feb 24 15:36:10 2017 +0000

    	PR rtl-optimizatoin/79286
    	* ira.c (update_equiv_regs): Drop may_trap_p exception to
    	dominance test.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245714 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 22964c8..1239c4a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-02-24  Jeff Law  <law@redhat.com>
+
+	PR rtl-optimizatoin/79286
+	* ira.c (update_equiv_regs): Drop may_trap_p exception to
+	dominance test.
+
 2017-02-24  Richard Biener  <rguenther@suse.de>
 
 	PR tree-optimization/79389
diff --git a/gcc/ira.c b/gcc/ira.c
index 6fb8aaf..b41c480 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -3551,8 +3551,7 @@ update_equiv_regs (void)
 	  if (DF_REG_DEF_COUNT (regno) == 1
 	      && note
 	      && !rtx_varies_p (XEXP (note, 0), 0)
-	      && (!may_trap_p (XEXP (note, 0))
-		  || def_dominates_uses (regno)))
+	      && def_dominates_uses (regno))
 	    {
 	      rtx note_value = XEXP (note, 0);
 	      remove_note (insn, note);

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-06-23  4:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-23 18:33 [PATCH][ PR rtl-optimization/79286] Drop may_trap_p exception to testing dominance in update_equiv_regs Bernd Edlinger
2017-04-28 17:17 ` Jeff Law
2017-04-28 18:05   ` Bernd Edlinger
2017-04-28 19:01     ` Jeff Law
2017-04-28 20:23       ` Bernd Edlinger
2017-04-28 20:27         ` Bernd Edlinger
2017-04-29  9:27       ` Bernd Edlinger
2017-05-12 16:49         ` [PING][PATCH][ " Bernd Edlinger
2017-06-01 16:00           ` [PING**2][PATCH][ " Bernd Edlinger
     [not found]           ` <59f99a5b-e5db-7078-5f55-c4b42f9c4a8b@hotmail.de>
2017-06-14 12:43             ` [PING**3][PATCH][ " Bernd Edlinger
2017-06-23  4:35         ` [PATCH][ " Jeff Law
  -- strict thread matches above, loose matches on Subject: below --
2017-02-24 15:48 Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).