Bug 29922 - [4.3 Regression] [Linux] ICE in insert_into_preds_of_block
Summary: [4.3 Regression] [Linux] ICE in insert_into_preds_of_block
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 blocker
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 30227 30244 30441 30713 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-11-21 01:41 UTC by happyarch
Modified: 2007-03-17 23:18 UTC (History)
13 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-11-21 07:47:57


Attachments
the preprocessed files and output (69.58 KB, application/x-zip-compressed)
2006-11-21 07:03 UTC, happyarch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description happyarch 2006-11-21 01:41:45 UTC
> pwd
/usr/src/linux-2.6.19-rc6
 > ls
COPYING  Documentation  MAINTAINERS  README          arch   crypto   fs       init  kernel  mm   scripts   sound
CREDITS  Kbuild         Makefile     REPORTING-BUGS  block  drivers  include  ipc   lib     net  security  usr
 > make menuconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/kconfig/conf.o
scripts/kconfig/conf.c: In function 'conf':
scripts/kconfig/conf.c:409: internal compiler error: in insert_into_preds_of_block, at tree-ssa-pre.c:2750
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Andrew Pinski 2006-11-21 02:00:12 UTC
Can you attach the preprocessed source?
Comment 2 happyarch 2006-11-21 03:17:44 UTC
I dunno, What is the preprocessed source?
conf.{c,o}?
Comment 3 Andrew Pinski 2006-11-21 03:22:43 UTC
(In reply to comment #2)
> I dunno, What is the preprocessed source?
> conf.{c,o}?

The .i file which is produced via adding -save-temps to the command that invokes GCC with.

This is all explained in http://gcc.gnu.org/bugs.html.

Comment 4 happyarch 2006-11-21 03:32:53 UTC
I see, i will attach the source.
But, it takes time, i can't access my computer ATM. 
Comment 5 happyarch 2006-11-21 07:03:50 UTC
Created attachment 12657 [details]
the preprocessed files and output
Comment 6 Andrew Pinski 2006-11-21 07:10:04 UTC
Reducing.
Comment 7 Andrew Pinski 2006-11-21 07:47:57 UTC
Confirmed, reduced testcase:
struct menu {
 struct menu *next;
 struct menu *list;
};
char line[128];
int conf_choice(struct menu *menu)
{
 struct menu *child;
 while (1)
 {
  for (child = menu->list; child; child = child->next)
 {
   if (menu_is_visible())
    break;
  }
  if (!child)
   continue;
  if (strlen(line) == 100)
 {
   f();
   continue;
  }
  return 1;
 }
}
Comment 8 Andrew Pinski 2006-11-21 07:50:18 UTC
This worked with "4.3.0 20061112" but fails with "4.3.0 20061119".
I think it was caused by:
2006-11-14  Daniel Berlin  <dberlin@dberlin.org>

        Fix PR tree-optimization/27755

Comment 9 Andrew Pinski 2006-11-25 09:13:21 UTC
(gdb) p debug_generic_expr (vh)
VH.22
$4 = void
(gdb) p debug_generic_expr (eprime)
strlen (&lineD.1610)
(gdb) p debug_generic_expr (vuse)
lineD.1610_11

We have:
  # NONLOCAL.5_14 = PHI <NONLOCAL.5_18(5)>;
  # line_11 = PHI <line_17(5)>;
<L4>:;
  #   VUSE <line_11>;
  #   VUSE <NONLOCAL.5_14>;
  D.1623_6 = strlen (&line);
  if (D.1623_6 == 100) goto <L6>; else goto <L7>;

Though the good question is why we have those PHIs still there even though they don't do anything except produce a copy.  All the copyprop passes as far as I can tell skip them because they are virtual.
Comment 10 Andrew Pinski 2006-11-27 07:51:56 UTC
(In reply to comment #9)
> Though the good question is why we have those PHIs still there even though they
> don't do anything except produce a copy.  All the copyprop passes as far as I
> can tell skip them because they are virtual.

The reason why they still exist is because they have a loop variant on the arugment which causes us to reject it during copyprop (and during dom).  I have a patch to remove the conditional on virtual operands but I don't know if this is enough to make sure we never produce this type of PHIs again.
Comment 11 Andrew Pinski 2006-11-27 08:06:29 UTC
Here is the patch which fixes the PHI issue but I don't know if it will always fix the PRE issue but I think it will as the PRE issue is always with VOPs:
Index: tree-ssa-dom.c
===================================================================
--- tree-ssa-dom.c      (revision 119245)
+++ tree-ssa-dom.c      (working copy)
@@ -1700,8 +1700,10 @@ cprop_operand (tree stmt, use_operand_p
         depth than the propagatee.  Otherwise, this may move loop variant
         variables outside of their loops and prevent coalescing
         opportunities.  If the value was loop invariant, it will be hoisted
-        by LICM and exposed for copy propagation.  */
-      if (loop_depth_of_name (val) > loop_depth_of_name (op))
+        by LICM and exposed for copy propagation.  We don't care much about
+         virtual operands.  */
+      if (loop_depth_of_name (val) > loop_depth_of_name (op)
+         && is_gimple_reg (val))
        return false;

       /* Dump details.  */
@@ -2136,12 +2138,13 @@ static void
 propagate_rhs_into_lhs (tree stmt, tree lhs, tree rhs, bitmap interesting_names)
 {
   /* First verify that propagation is valid and isn't going to move a
-     loop variant variable outside its loop.  */
+     loop variant variable outside its loop except for vops.  */
   if (! SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs)
       && (TREE_CODE (rhs) != SSA_NAME
          || ! SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs))
       && may_propagate_copy (lhs, rhs)
-      && loop_depth_of_name (lhs) >= loop_depth_of_name (rhs))
+      && (loop_depth_of_name (lhs) > loop_depth_of_name (rhs)
+         || !is_gimple_reg (lhs)))
     {
       use_operand_p use_p;
       imm_use_iterator iter;
Index: tree-ssa-copy.c
===================================================================
--- tree-ssa-copy.c     (revision 119245)
+++ tree-ssa-copy.c     (working copy)
@@ -801,8 +801,10 @@ copy_prop_visit_phi_node (tree phi)
         Otherwise, this may move loop variant variables outside of
         their loops and prevent coalescing opportunities.  If the
         value was loop invariant, it will be hoisted by LICM and
-        exposed for copy propagation.  */
-      if (loop_depth_of_name (arg) > loop_depth_of_name (lhs))
+        exposed for copy propagation.  We don't much about virtual
+        operands as they don't cause any LICM to happen.  */
+      if (loop_depth_of_name (arg) > loop_depth_of_name (lhs)
+         && is_gimple_reg (arg))
        {
          phi_val.value = lhs;
          break;
Comment 12 pinskia@gmail.com 2006-11-27 17:23:20 UTC
Subject: Re:  [4.3 Regression] [Linux] ICE in
	insert_into_preds_of_block

On Mon, 2006-11-27 at 08:06 +0000, pinskia at gcc dot gnu dot org wrote:
> 
> ------- Comment #11 from pinskia at gcc dot gnu dot org  2006-11-27 08:06 -------
> Here is the patch which fixes the PHI issue but I don't know if it will always
> fix the PRE issue but I think it will as the PRE issue is always with VOPs:

I am hiding a PRE bug but there is no reason for these PHIs to be there
anyways as far as I can tell so I am still going to submit my patch for
the PHIs but will keep this bug opened.

Thanks,
Andrew Pinski

Comment 13 Andrew Pinski 2006-12-15 22:08:44 UTC
*** Bug 30227 has been marked as a duplicate of this bug. ***
Comment 14 Andrew Pinski 2006-12-18 09:33:15 UTC
*** Bug 30244 has been marked as a duplicate of this bug. ***
Comment 15 kargls 2006-12-19 21:55:56 UTC
Just a note here.  My recent compilation of LAPACK with gfortran has stumbled onto to this bug.

gfc -w -c -O3 -march=opteron -funroll-loops -ftree-vectorize \
-I/home/kargl/opt/modules sget33.f
sget33.f: In function 'sget33':
sget33.f:1: internal compiler error: in insert_into_preds_of_block, at tree-ssa-pre.c:2750
Please submit a full bug report,
Comment 16 Daniel Berlin 2006-12-20 02:55:38 UTC
Subject: Re:  [4.3 Regression] [Linux] ICE in insert_into_preds_of_block

I will try to get back to this bug this week. I was fighting some
other fights last week, i apologize.
Comment 17 Andrew Pinski 2007-01-11 18:28:04 UTC
*** Bug 30441 has been marked as a duplicate of this bug. ***
Comment 18 Andrew Pinski 2007-02-09 19:00:08 UTC
*** Bug 30713 has been marked as a duplicate of this bug. ***
Comment 19 Martin Michlmayr 2007-03-05 10:13:20 UTC
> I will try to get back to this bug this week. I was fighting some
> other fights last week, i apologize.

Danny, any update on this?
Comment 20 Daniel Berlin 2007-03-09 17:55:21 UTC
Uh, i think i accidentally fixed the reduced testcase with my recent alias patch (r122741).
Are the others still failing?
Comment 21 Martin Michlmayr 2007-03-09 19:28:44 UTC
(In reply to comment #20)
> Uh, i think i accidentally fixed the reduced testcase with my recent alias
> patch (r122741).
> Are the others still failing?

Yes, conf.i is still failing at -O2
Comment 22 Martin Michlmayr 2007-03-09 19:34:34 UTC
Testcase based on conf.i:

struct symbol
{
  char *help;
};
struct menu
{
  struct menu *next;
  struct menu *list;
  struct symbol *sym;
};
enum
{
  ask_all,
}
input_mode = ask_all;
static char line[128];
static char nohelp_text[] =
  ("Sorry, no help available for this option yet.\n");
conf_choice (struct menu *menu)
{
  struct menu *child;
  while (1)
    {
      int cnt, def;
    conf_childs:for (child = menu->list; child; child = child->next)
        {
          if (!child->sym || !menu_is_visible (child))
          if (!--cnt)
            break;
        }
      if (!child)
        continue;
      if (line[strlen (line) - 1] == '?')
        {
          printf ("\n%s\n", child->sym->help ? child->sym->help : "");
          continue;
        }
      return 1;
    }
}
Comment 23 Jean-Pierre Vial 2007-03-10 08:48:05 UTC
the two test files from the LAPACK library
dget33.f and sget33.f whose compilation with gfortran failed
with -O3 optmisation are now compiled without error or warning.
tested with gfortran 4.3 experimental (svn) dated 20070309 and 20070222
Comment 24 Daniel Berlin 2007-03-17 23:07:49 UTC
Subject: Bug 29922

Author: dberlin
Date: Sat Mar 17 23:07:34 2007
New Revision: 123029

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123029
Log:
2007-03-16  Daniel Berlin  <dberlin@dberlin.org>

	Fix PR tree-optimization/29922
	* tree-ssa-pre.c (bb_bitmap_sets): Remove RVUSE_* members.
	(get_representative): Removed.
	(value_dies_in_block_x): Update for rvuse removal.
	(valid_in_sets): Update for renaming of vuses_dies_in_block_x.
	(compute_antic_aux): Handle when PHI nodes appear in
	non-single-successors. 
	(dump_bitmap_of_names): Removed.
	(compute_antic_safe): Renamed and removed rvuse calculation.
	Calculate only antic safe.
	(insert_into_preds_of_block): Remove assert.
	(execute_pre): Update for renamed functions.
	(defer_or_phi_translate_block): New function.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/loadpre12.c
    trunk/gcc/tree-ssa-pre.c

Comment 25 Martin Michlmayr 2007-03-17 23:16:53 UTC
Thanks, Danny!
Comment 26 Daniel Berlin 2007-03-17 23:18:53 UTC
Sorry for the delay.
Fixed now.