Bug 69013 - [5/6 Regression] gfortran-5.3.0 ICE in prune_uninit_phi_opnds_in_unrealizable_paths, at tree-ssa-uninit.c:1121
Summary: [5/6 Regression] gfortran-5.3.0 ICE in prune_uninit_phi_opnds_in_unrealizable...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 5.3.0
: P3 normal
Target Milestone: 5.4
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2015-12-22 12:58 UTC by George N. White III
Modified: 2016-01-13 12:18 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.9.3, 5.4.0, 6.0
Known to fail: 5.3.0
Last reconfirmed: 2015-12-22 00:00:00


Attachments
source file from ncarg 6.3.0 <http://www.ncl.ucar.edu/> (7.32 KB, text/plain)
2015-12-22 12:58 UTC, George N. White III
Details
log file for test compile (1.98 KB, text/plain)
2015-12-22 13:02 UTC, George N. White III
Details

Note You need to log in before you can comment on or make changes to this bug.
Description George N. White III 2015-12-22 12:58:07 UTC
Created attachment 37104 [details]
source file from ncarg 6.3.0 <http://www.ncl.ucar.edu/>

Using gcc-5.3.0 from Macports on OS X Mavericks, the command:

/opt/local/bin/gfortran-mp-5 -fPIC -fno-range-check -m64 -Wall  -O2 -c -o vtcudr.o vtcudr.f

internal compiler error: in prune_uninit_phi_opnds_in_unrealizable_paths, at tree-ssa-uninit.c:1121

vtcudr.f:1:0: internal compiler error: Abort trap: 6
gfortran-mp-5: internal compiler error: Abort trap: 6 (program f951)
Please submit a full bug report,

This is a regression from macports' gcc-5.2.0.
Comment 1 George N. White III 2015-12-22 13:02:30 UTC
Created attachment 37105 [details]
log file for test compile

Compile command:

/opt/local/bin/gfortran-mp-5 -v --save-temps -fPIC -fno-range-check -m64 -Wall  -Os    -c -o vtcudr.o vtcudr.f > vtcudr.log 2>&1
Comment 2 Dominique d'Humieres 2015-12-22 15:08:10 UTC
Confirmed with gcc-5.3.0 and gcc-5.3.1. This has been fixed/hidden on trunk (6.0) between revisions r226476 (2015-08-02, ICE) and r227016 (2015-08-19, compiles). The minimal set of options on x86_64-apple-darwin14 is '-O -Wall' (-fPIC -m64 being the default). AFAICT this does not seems a gfortran problem.
Comment 3 Jakub Jelinek 2015-12-22 15:46:32 UTC
Stopped being reproduceable with r226901, so most likely just went latent.
Started with r219739 aka PR64614, which has been a tree-ssa-uninit.c change.
Comment 4 Richard Biener 2016-01-08 08:53:45 UTC
I dont' know the code good enough but the assert might be bogus?  Thus

Index: gcc/tree-ssa-uninit.c
===================================================================
--- gcc/tree-ssa-uninit.c       (revision 231672)
+++ gcc/tree-ssa-uninit.c       (working copy)
@@ -1118,14 +1118,16 @@ prune_uninit_phi_opnds_in_unrealizable_p
               edge opnd_edge;
               unsigned uninit_opnds2
                   = compute_uninit_opnds_pos (opnd_def_phi);
-              gcc_assert (!MASK_EMPTY (uninit_opnds2));
-              opnd_edge = gimple_phi_arg_edge (phi, i);
-              if (!is_use_properly_guarded (phi,
-                                            opnd_edge->src,
-                                            opnd_def_phi,
-                                            uninit_opnds2,
-                                            visited_phis))
-                  return false;
+              if (!MASK_EMPTY (uninit_opnds2))
+               {
+                 opnd_edge = gimple_phi_arg_edge (phi, i);
+                 if (!is_use_properly_guarded (phi,
+                                               opnd_edge->src,
+                                               opnd_def_phi,
+                                               uninit_opnds2,
+                                               visited_phis))
+                   return false;
+               }
             }
           else
             return false;

"fixes" it.  Marking as 6 regression as well because it's clearly only latent.

A smaller testcase for easier investigation would be nice.

Not sure if David is still around...
Comment 5 davidxl 2016-01-09 05:19:19 UTC
The assertion is indeed too strict. See

static unsigned
compute_uninit_opnds_pos (gphi *phi)
{
  size_t i, n;
  unsigned uninit_opnds = 0;

  n = gimple_phi_num_args (phi);
  /* Bail out for phi with too many args.  */
  if (n > 32)
    return 0;
 ...
}

it is possible that empty bitset is returned -- so the fix looks ok.
Comment 6 Richard Biener 2016-01-13 12:15:36 UTC
Author: rguenth
Date: Wed Jan 13 12:15:01 2016
New Revision: 232320

URL: https://gcc.gnu.org/viewcvs?rev=232320&root=gcc&view=rev
Log:
2016-01-13  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/69013
	* tree-ssa-uninit.c (prune_uninit_phi_opnds_in_unrealizable_paths):
	Exchange assert for a test.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-uninit.c
Comment 7 Richard Biener 2016-01-13 12:18:26 UTC
Fixed.
Comment 8 Richard Biener 2016-01-13 12:18:34 UTC
Author: rguenth
Date: Wed Jan 13 12:18:02 2016
New Revision: 232321

URL: https://gcc.gnu.org/viewcvs?rev=232321&root=gcc&view=rev
Log:
2016-01-13  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/69013
	* tree-ssa-uninit.c (prune_uninit_phi_opnds_in_unrealizable_paths):
	Exchange assert for a test.

Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/tree-ssa-uninit.c