Bug 79315 - [7 Regression] ICE while building SPEC CPU 2006 FP with -Ofast -ftree-parallelize-loops
Summary: [7 Regression] ICE while building SPEC CPU 2006 FP with -Ofast -ftree-paralle...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 7.0
: P1 normal
Target Milestone: 7.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2017-02-01 02:35 UTC by Andrew Pinski
Modified: 2019-02-22 11:27 UTC (History)
0 users

See Also:
Host:
Target: aarch64-linux-gnu, x86_64-*-*
Build:
Known to work: 6.3.1
Known to fail: 7.0
Last reconfirmed: 2017-02-01 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2017-02-01 02:35:55 UTC
I don't know if this is a GCC 7 regression or not.
Compiling wrf in SPEC CPU 2006 FP  with -Ofast -ftree-parallelize-loops produces an ICE about location references block not in block tree.

Reduced example:
SUBROUTINE wsm32D(t, &
   w, &
   den, &
   p, &
   delz, &
                     its,&
   ite, &
   kts, &
   kte  &
                      )
  REAL, DIMENSION( its:ite , kts:kte ),                           &
        INTENT(INOUT) ::                                          &
                                                               t
  REAL, DIMENSION( ims:ime , kms:kme ),                           &
        INTENT(IN   ) ::                                       w, &
                                                             den, &
                                                               p, &
                                                            delz
  REAL, DIMENSION( its:ite , kts:kte ) ::                         &
        qs, &
        xl, &
        work1, &
        work2, &
        qs0, &
        n0sfac
      diffus(x,y) = 8.794e-5*x**1.81/y
      diffac(a,b,c,d,e) = d*a*a/(xka(c,d)*rv*c*c)+1./(e*diffus(c,b))
      venfac(a,b,c) = (viscos(b,c)/diffus(b,a))**(.3333333)       &
             /viscos(b,c)**(.5)*(den0/c)**0.25
      do loop = 1,loops
      xa=-dldt/rv
      do k = kts, kte
        do i = its, ite
          tr=ttp/t(i,k)
          if(t(i,k).lt.ttp) then
            qs(i,k) =psat*(tr**xa)*exp(xb*(1.-tr))
          endif
          qs0(i,k)  =psat*(tr**xa)*exp(xb*(1.-tr))
        enddo
        do i = its, ite
          if(t(i,k).ge.t0c) then
            work1(i,k) = diffac(xl(i,k),p(i,k),t(i,k),den(i,k),qs(i,k))
          endif
          work2(i,k) = venfac(p(i,k),t(i,k),den(i,k))
        enddo
      enddo
      enddo                  ! big loops
END SUBROUTINE wsm32D

This produces:

t.f90:1:0:

 SUBROUTINE wsm32D(t, &

Error: location references block not in block tree
__builtin_powf
_224 = __builtin_powf (_38, 1.809999942779541015625e+0);
t.f90:1:0: Error: location references block not in block tree
__builtin_powf
_229 = __builtin_powf (pretmp_227, 1.809999942779541015625e+0);
t.f90:1:0: internal compiler error: verify_gimple failed
0xc37737 verify_gimple_in_cfg(function*, bool)
        ../../gcc/gcc/tree-cfg.c:5266
0xb14063 execute_function_todo
        ../../gcc/gcc/passes.c:1966
0xb151d3 execute_todo
        ../../gcc/gcc/passes.c:2016
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Andrew Pinski 2017-02-01 02:43:42 UTC
gamess also fails the same way.
Comment 2 Richard Biener 2017-02-01 09:04:52 UTC
Probably a "regression" since we do this verification.  I'll try to reproduce on x86_64.
Comment 3 ktkachov 2017-02-01 09:30:58 UTC
Confirmed the ICE on the testcase.
Doesn't ICE for me with GCC 6 so it's a regression
Comment 4 Richard Biener 2017-02-01 09:37:18 UTC
The bogus location is on &__builtin_powf in

_224 = __builtin_powf (_38, 1.809999942779541015625e+0);

in wsm32d.  It gets the location via

#1  0x0000000000ff33a5 in move_stmt_op (tp=0x7ffff66b3a90, 
    walk_subtrees=0x7fffffffd338, data=0x7fffffffd550)
    at /space/rguenther/src/svn/gcc-7-branch/gcc/tree-cfg.c:6642
6642            TREE_SET_BLOCK (t, p->new_block);
...
#5  0x0000000000ff3ed7 in move_block_to_fn (dest_cfun=0x7ffff6a88160, 
    bb=<basic_block 0x7ffff66f2618 (32)>, 
    after=<basic_block 0x7ffff68ab4e0 (8)>, update_edge_count_p=true, 
    d=0x7fffffffd6e0)
    at /space/rguenther/src/svn/gcc-7-branch/gcc/tree-cfg.c:6922
#6  0x0000000000ff5783 in move_sese_region_to_fn (dest_cfun=0x7ffff6a88160, 

(gdb) l
6637        {
6638          tree block = TREE_BLOCK (t);
6639          if (block == p->orig_block
6640              || (p->orig_block == NULL_TREE
6641                  && block != NULL_TREE))
6642            TREE_SET_BLOCK (t, p->new_block);
6643          else if (flag_checking && block != NULL_TREE)
6644            {
6645              while (block && TREE_CODE (block) == BLOCK && block != p->orig_block)
6646                block = BLOCK_SUPERCONTEXT (block);
(gdb) p p->orig_bock
There is no member named orig_bock.
(gdb) p p->orig_block
$18 = <tree 0x0>
(gdb) p block
$19 = <tree 0x0>
(gdb) p p->new_block
$20 = <block 0x7ffff6a94840>

probably not a good idea to simply set TREE_BLOCK on a tree node that can
be shared... (from a NULL TREE_BLOCK even).
Comment 5 Richard Biener 2017-02-01 09:40:04 UTC
Will test

Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c      (revision 245064)
+++ gcc/tree-cfg.c      (working copy)
@@ -6636,11 +6636,12 @@ move_stmt_op (tree *tp, int *walk_subtre
   if (EXPR_P (t))
     {
       tree block = TREE_BLOCK (t);
-      if (block == p->orig_block
-         || (p->orig_block == NULL_TREE
-             && block != NULL_TREE))
+      if (block == NULL_TREE)
+       ;
+      else if (block == p->orig_block
+              || p->orig_block == NULL_TREE)
        TREE_SET_BLOCK (t, p->new_block);
-      else if (flag_checking && block != NULL_TREE)
+      else if (flag_checking)
        {
          while (block && TREE_CODE (block) == BLOCK && block != p->orig_block)
            block = BLOCK_SUPERCONTEXT (block);
Comment 6 Richard Biener 2017-02-01 10:20:08 UTC
On x86_64 I see a similar ICE when building 416.gamess
Comment 7 Richard Biener 2017-02-01 12:47:57 UTC
Author: rguenth
Date: Wed Feb  1 12:47:25 2017
New Revision: 245089

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

	PR middle-end/79315
	* tree-cfg.c (move_stmt_op): Never set TREE_BLOCK when it
	was not set before.

	* gfortran.dg/pr79315.f90: New testcase.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr79315.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfg.c
Comment 8 Andrew Pinski 2017-02-01 20:46:17 UTC
Fixed and tested on aarch64-linux-gnu so closing.
Comment 9 Andrew Pinski 2017-02-01 20:46:25 UTC
.