Bug 44485 - [4.6 Regression] ICE in get_expr_operands, at tree-ssa-operands.c:1020
Summary: [4.6 Regression] ICE in get_expr_operands, at tree-ssa-operands.c:1020
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Jan Hubicka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-09 21:02 UTC by John Regehr
Modified: 2014-02-16 13:17 UTC (History)
5 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2010-06-10 15:04:31


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2010-06-09 21:02:03 UTC
regehr@gamow tmp414]$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r160490-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto --prefix=/home/regehr/z/compiler-install/gcc-r160490-install --program-prefix=r160490- --enable-languages=c,c++
Thread model: posix
gcc version 4.6.0 20100609 (experimental) (GCC) 

[regehr@gamow tmp414]$ current-gcc -c -O small.c

small.c: In function 'func_21':
small.c:42:22: warning: assignment makes integer from pointer without a cast [enabled by default]
unhandled expression in get_expr_operands():
 <error_mark 0x7fa3684399f0>

small.c: In function 'int324':
small.c:21:6: internal compiler error: in get_expr_operands, at tree-ssa-operands.c:1020
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

[regehr@gamow tmp414]$ cat small.c

static int
foo (int si1, int si2)
{
  return si1 > 0 && si2 > 0 && si1 > -si2 || si1 < 0 && si2 < 0
    && si1 < -si2 ? : si1 + si2;
}

struct S0
{
  unsigned short f1;
};
int g_4;
struct S0 g_54 = {
  3428
};

int
func_21 (int * p_22, int * const int32p_24, unsigned p_25,
	 const int * p_26);

void int324 (unsigned p_15, int * p_16, int * p_17, int * p_18)
{
  if (foo (g_4, func_21 (p_18, &g_4, 0, 0)))
    {
      for (g_54.f1; g_54.f1; g_54.f1 += 1)
	{
	}
    }
}

int
func_21 (int * p_22, int * const int32p_24, unsigned p_25,
	 const int * p_26)
{
  for (0; 1; p_25 += 1)
  lbl_29:if (p_25)
      goto lbl_28;
lbl_28:for (p_25 = 0; p_25 < 9; p_25 += 1)
    if (p_25)
      goto lbl_29;
  unsigned short l_53;
  for (0; l_53; l_53 = foo)
    {
    }
  return 0;
}
Comment 1 H.J. Lu 2010-06-09 21:40:57 UTC
It is caused by revision 160124:

http://gcc.gnu.org/ml/gcc-cvs/2010-06/msg00036.html
Comment 2 Jan Hubicka 2010-06-10 15:04:31 UTC
Testing fix.
Comment 3 Jan Hubicka 2010-06-12 12:43:24 UTC
Subject: Bug 44485

Author: hubicka
Date: Sat Jun 12 12:43:02 2010
New Revision: 160659

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160659
Log:
	PR tree-optimize/44485
	* tree-cfgcleanup.c (fixup_noreturn_call): Remove basic blocks containing
	use of return value of noreturn function.
	* gcc.c-torture/compile/pc44485.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pc44485.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfgcleanup.c

Comment 4 Zdenek Sojka 2010-06-14 01:25:21 UTC
I am not sure if that's related, but the testcase fails with -O -funsafe-loop-optimizations in r160687/x86_64-linux:

$ /mnt/svn/gcc-trunk/binary-160687-lto-fortran-checking-yes-rtl/bin/gcc -O1 -funsafe-loop-optimizations pc44485.c
pc44485.c: In function 'func_21':
pc44485.c:42:22: warning: assignment makes integer from pointer without a cast [enabled by default]
pc44485.c: In function 'int324':
pc44485.c:21:6: internal compiler error: in execute_todo, at passes.c:1285
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Is the name of the testcase, pc44485.c, a typo, or is the 'c' intentional?
Comment 5 Richard Biener 2010-07-23 12:01:32 UTC
Probably related.  Honza?
Comment 6 Jakub Jelinek 2010-08-25 16:39:16 UTC
The problem is that func_21 is first marked as TREE_READONLY/DECL_LOOPING_CONST_OR_PURE_P by local_pure_const, thus there are no vops on it, but afterwards it is by another local_pure_const made
also TREE_THIS_VOLATILE (i.e. noreturn).
flags_from_decl_or_type doesn't set ECF_CONST for const noreturn functions though for some reason:
603      /* Process the pure and const attributes.  */
604      if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
605        flags |= ECF_CONST;
606      if (DECL_PURE_P (exp))
607        flags |= ECF_PURE;
(strangely it does set ECF_PURE for pure noreturn calls), which means when fixup_noreturn_call calls update_stmt to drop lhs from the call, it adds vops that were missing before and .MEM needs renaming, but the pass in which fixup_noreturn_call is called doesn't expect that ssa needs updating.
I wonder what is the reason for that " && ! TREE_THIS_VOLATILE (exp)" above.
Comment 7 Richard Biener 2010-08-25 17:26:47 UTC
(In reply to comment #6)
> The problem is that func_21 is first marked as
> TREE_READONLY/DECL_LOOPING_CONST_OR_PURE_P by local_pure_const, thus there are
> no vops on it, but afterwards it is by another local_pure_const made
> also TREE_THIS_VOLATILE (i.e. noreturn).
> flags_from_decl_or_type doesn't set ECF_CONST for const noreturn functions
> though for some reason:
> 603      /* Process the pure and const attributes.  */
> 604      if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
> 605        flags |= ECF_CONST;
> 606      if (DECL_PURE_P (exp))
> 607        flags |= ECF_PURE;
> (strangely it does set ECF_PURE for pure noreturn calls), which means when
> fixup_noreturn_call calls update_stmt to drop lhs from the call, it adds vops
> that were missing before and .MEM needs renaming, but the pass in which
> fixup_noreturn_call is called doesn't expect that ssa needs updating.
> I wonder what is the reason for that " && ! TREE_THIS_VOLATILE (exp)" above.

I'd say remove it - it probably was a measure to avoid DCEing the side-effect
or so, before we had proper looping-pure-or-const.
Comment 8 Jakub Jelinek 2010-08-26 16:39:41 UTC
Subject: Bug 44485

Author: jakub
Date: Thu Aug 26 16:39:26 2010
New Revision: 163568

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163568
Log:
	PR tree-optimization/44485
	* calls.c (flags_from_decl_or_type): For const or pure
	noreturn functions return ECF_LOOPING_CONST_OR_PURE|ECF_NORETURN
	together with ECF_CONST resp. ECF_PURE.
	* builtins.c (expand_builtin): Use flags_from_decl_or_type
	instead of querying flags directly.
	* tree-ssa-loop-niter.c (finite_loop_p): Likewise.
	* tree-ssa-dce.c (find_obviously_necessary_stmts): Likewise.

	* gcc.dg/pr44485.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr44485.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/calls.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-dce.c
    trunk/gcc/tree-ssa-loop-niter.c

Comment 9 Jakub Jelinek 2010-08-26 16:48:06 UTC
Should be fixed now.
Comment 10 Jackie Rosen 2014-02-16 13:17:10 UTC Comment hidden (spam)