public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fix SSA_NAME_OCCURS_IN_ABNORMAL_PHI issue in backprop
@ 2016-02-08 10:37 Eric Botcazou
  2016-02-08 11:05 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2016-02-08 10:37 UTC (permalink / raw)
  To: gcc-patches

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

Hi,

the Ada runtime fails to build for platforms still using the old SJLJ scheme 
because of the new GIMPLE backprop pass (hence it's a regression):

eric@polaris:~/build/gcc/native> gcc/gnat1 -quiet a-ncelfu.ads -gnatpg -O -I 
~/svn/gcc/gcc/ada/
a-ngcefu.adb: In function 'Ada.Numerics.Complex_Elementary_Functions.Sqrt':
a-ngcefu.adb:16:4: error: SSA_NAME_OCCURS_IN_ABNORMAL_PHI should be set
for SSA_NAME: _28 in statement:
xr_3(ab) = PHI <xr_22(D)(ab)(2), xr_22(D)(ab)(3), xr_22(D)(ab)(4), _28(5), 
_28(6), _28(7), xr_4(ab)(11), xr_4(ab)(12), xr_4(ab)(14), xr_4(ab)(15), 
xr_4(ab)(16), xr_4(ab)(17), xr_4(ab)(18), xr_4(ab)(19), xr_4(ab)(20), xr_4(ab)
(21), xr_4(ab)(22), xr_4(ab)(23), xr_4(ab)(24), xr_4(ab)(25), xr_4(ab)(26), 
xr_4(ab)(27), xr_4(ab)(28), xr_4(ab)(29), xr_4(ab)(30), xr_4(ab)(32), xr_4(ab)
(34), xr_4(ab)(36), xr_4(ab)(37)>
PHI argument
_28
for PHI node
xr_3(ab) = PHI <xr_22(D)(ab)(2), xr_22(D)(ab)(3), xr_22(D)(ab)(4), _28(5), 
_28(6), _28(7), xr_4(ab)(11), xr_4(ab)(12), xr_4(ab)(14), xr_4(ab)(15), 
xr_4(ab)(16), xr_4(ab)(17), xr_4(ab)(18), xr_4(ab)(19), xr_4(ab)(20), xr_4(ab)
(21), xr_4(ab)(22), xr_4(ab)(23), xr_4(ab)(24), xr_4(ab)(25), xr_4(ab)(26), 
xr_4(ab)(27), xr_4(ab)(28), xr_4(ab)(29), xr_4(ab)(30), xr_4(ab)(32), xr_4(ab)
(34), xr_4(ab)(36), xr_4(ab)(37)>
+===========================GNAT BUG DETECTED==============================+
| 6.0.0 20160206 (experimental) [trunk revision 233194] (x86_64-suse-linux) 
GCC error:|
| verify_ssa failed                                                        |
| Error detected around a-ngcefu.adb:16:4  

The problem is that the pass propagates the source RHS (_28) of:

  xr_29(ab) = ABS_EXPR <_28>;

into a PHI note using xr_29 along an AB edge so the above check triggers.

I think replacing such an AB SSA_NAME is problematic in any case: if the RHS 
is not AB, then the check triggers; if the RHS is also AB, then we may create 
overlapping live ranges and the compilation will abort later.  We can probably 
create a new SSA_NAME but it's not really the spirit of the backprop pass and 
I'm not sure it's worth the hassle, hence the minimal attached fixlet.

Tested on x86_64-suse-linux, OK for the mainline?


2016-02-08  Eric Botcazou  <ebotcazou@adacore.com>

	* gimple-ssa-backprop.c (optimize_phi): Do not replace an argument
	with SSA_NAME_OCCURS_IN_ABNORMAL_PHI set.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 810 bytes --]

Index: gimple-ssa-backprop.c
===================================================================
--- gimple-ssa-backprop.c	(revision 233194)
+++ gimple-ssa-backprop.c	(working copy)
@@ -840,13 +840,14 @@ backprop::optimize_phi (gphi *phi, tree
       bool replaced = false;
       FOR_EACH_PHI_ARG (use, phi, oi, SSA_OP_USE)
 	{
-	  tree new_arg = strip_sign_op (USE_FROM_PTR (use));
-	  if (new_arg)
+	  tree arg = USE_FROM_PTR (use);
+	  tree new_arg = strip_sign_op (arg);
+	  if (new_arg && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (arg))
 	    {
 	      if (!replaced)
 		prepare_change (var);
 	      if (dump_file && (dump_flags & TDF_DETAILS))
-		note_replacement (phi, USE_FROM_PTR (use), new_arg);
+		note_replacement (phi, arg, new_arg);
 	      replace_exp (use, new_arg);
 	      replaced = true;
 	    }

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

* Re: [patch] Fix SSA_NAME_OCCURS_IN_ABNORMAL_PHI issue in backprop
  2016-02-08 10:37 [patch] Fix SSA_NAME_OCCURS_IN_ABNORMAL_PHI issue in backprop Eric Botcazou
@ 2016-02-08 11:05 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-02-08 11:05 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches

On Mon, Feb 8, 2016 at 11:37 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> the Ada runtime fails to build for platforms still using the old SJLJ scheme
> because of the new GIMPLE backprop pass (hence it's a regression):
>
> eric@polaris:~/build/gcc/native> gcc/gnat1 -quiet a-ncelfu.ads -gnatpg -O -I
> ~/svn/gcc/gcc/ada/
> a-ngcefu.adb: In function 'Ada.Numerics.Complex_Elementary_Functions.Sqrt':
> a-ngcefu.adb:16:4: error: SSA_NAME_OCCURS_IN_ABNORMAL_PHI should be set
> for SSA_NAME: _28 in statement:
> xr_3(ab) = PHI <xr_22(D)(ab)(2), xr_22(D)(ab)(3), xr_22(D)(ab)(4), _28(5),
> _28(6), _28(7), xr_4(ab)(11), xr_4(ab)(12), xr_4(ab)(14), xr_4(ab)(15),
> xr_4(ab)(16), xr_4(ab)(17), xr_4(ab)(18), xr_4(ab)(19), xr_4(ab)(20), xr_4(ab)
> (21), xr_4(ab)(22), xr_4(ab)(23), xr_4(ab)(24), xr_4(ab)(25), xr_4(ab)(26),
> xr_4(ab)(27), xr_4(ab)(28), xr_4(ab)(29), xr_4(ab)(30), xr_4(ab)(32), xr_4(ab)
> (34), xr_4(ab)(36), xr_4(ab)(37)>
> PHI argument
> _28
> for PHI node
> xr_3(ab) = PHI <xr_22(D)(ab)(2), xr_22(D)(ab)(3), xr_22(D)(ab)(4), _28(5),
> _28(6), _28(7), xr_4(ab)(11), xr_4(ab)(12), xr_4(ab)(14), xr_4(ab)(15),
> xr_4(ab)(16), xr_4(ab)(17), xr_4(ab)(18), xr_4(ab)(19), xr_4(ab)(20), xr_4(ab)
> (21), xr_4(ab)(22), xr_4(ab)(23), xr_4(ab)(24), xr_4(ab)(25), xr_4(ab)(26),
> xr_4(ab)(27), xr_4(ab)(28), xr_4(ab)(29), xr_4(ab)(30), xr_4(ab)(32), xr_4(ab)
> (34), xr_4(ab)(36), xr_4(ab)(37)>
> +===========================GNAT BUG DETECTED==============================+
> | 6.0.0 20160206 (experimental) [trunk revision 233194] (x86_64-suse-linux)
> GCC error:|
> | verify_ssa failed                                                        |
> | Error detected around a-ngcefu.adb:16:4
>
> The problem is that the pass propagates the source RHS (_28) of:
>
>   xr_29(ab) = ABS_EXPR <_28>;
>
> into a PHI note using xr_29 along an AB edge so the above check triggers.
>
> I think replacing such an AB SSA_NAME is problematic in any case: if the RHS
> is not AB, then the check triggers; if the RHS is also AB, then we may create
> overlapping live ranges and the compilation will abort later.  We can probably
> create a new SSA_NAME but it's not really the spirit of the backprop pass and
> I'm not sure it's worth the hassle, hence the minimal attached fixlet.

I think the problematic transform is when the replacement happens on a PHI arg
with its edge being abnormal only.  Thus simply do

  if (EDGE_PRED (gimple_bb (phi), PHI_ARG_INDEX_FROM_USE (use))->flags
& EDGE_ABNORMAL)
   continue;

at the start of the FOR_EACH_PHI_ARG body.

Thanks,
Richard.

> Tested on x86_64-suse-linux, OK for the mainline?
>
>
> 2016-02-08  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * gimple-ssa-backprop.c (optimize_phi): Do not replace an argument
>         with SSA_NAME_OCCURS_IN_ABNORMAL_PHI set.
>
> --
> Eric Botcazou

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

end of thread, other threads:[~2016-02-08 11:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 10:37 [patch] Fix SSA_NAME_OCCURS_IN_ABNORMAL_PHI issue in backprop Eric Botcazou
2016-02-08 11:05 ` Richard Biener

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).