Bug 37258 - [4.4 Regression] ice in simplify_subreg, at simplify-rtx.c:4957
Summary: [4.4 Regression] ice in simplify_subreg, at simplify-rtx.c:4957
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P1 normal
Target Milestone: 4.4.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2008-08-27 17:35 UTC by John Regehr
Modified: 2008-09-18 15:46 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2008-08-27 19:35:16


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2008-08-27 17:35:35 UTC
Seen using r139610 on Ubuntu Feisty.

[regehr@babel tmp13]$ current-gcc -O2 -w small.c

small.c: In function ‘func_77’:
small.c:33: internal compiler error: in simplify_subreg, at simplify-rtx.c:4957
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

[regehr@babel tmp13]$ current-gcc -v

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --program-prefix=current- --enable-languages=c,c++ --prefix=/home/regehr : (reconfigured) ../configure --program-prefix=current- --enable-languages=c,c++ --prefix=/home/regehr
Thread model: posix
gcc version 4.4.0 20080826 (experimental) (GCC) 

[regehr@babel tmp13]$ cat small.c

typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
__extension__ typedef long long int int64_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
static inline unsigned int
lshift_u_s (unsigned int left, int right)
{
  if ((right) || (right >= sizeof (unsigned int) * 8)
      || (left > (4294967295U >> right)))
    return left;
}
static inline unsigned long int
div_rhs (long int rhs)
{
  if (rhs == 0)
    return 1;
  return rhs;
}

uint32_t g_230;
int8_t g_294;
uint16_t g_316;
uint32_t g_334;
int32_t g_375;
int64_t g_380;
int32_t func_99 (int16_t p_100, int32_t p_101, int32_t p_102, int32_t p_103,
                 int64_t p_105, int32_t p_106, int32_t p_107, int16_t p_108,
                 int16_t p_109);
int32_t
func_77 (int64_t p_79)
{
  int16_t l_397;
  if (mod_rhs (p_79))
    p_79 = 1;
  else
    for (p_79 = 0; 0; p_79 += 1)
      {
      }
  if (lshift_s_s (1, func_112 (2L, (lshift_u_s (g_334, p_79)))))
    {
      int8_t l_384;
      int64_t l_414;
      if (lshift_u_s (g_375, 1))
        {
          func_23 (func_99 (1, 1, 1, 1, g_230, p_79, 1, g_334, 1), 1);
          for (p_79 = 0; 0; ++p_79)
            {
            }
        }
      if (div_rhs (func_82 (1, 1, g_380, 1, l_397, 1, 1)))
        func_99 ((func_82
                  (1, g_334, g_294, func_112 (1, (p_79 & 1)), g_316, 1, 1)),
                 1, (0xFBA25CA382A8CA74LL), l_384, l_414, 0L, 1, 1, 1);
    }
}
[regehr@babel tmp13]$
Comment 1 John Regehr 2008-08-27 17:37:04 UTC
Also happens on r139628.
Comment 2 Richard Biener 2008-08-27 19:35:15 UTC
Confirmed.

#1  0x0845d476 in simplify_subreg (outermode=SImode, op=0xb7d50d2c, 
    innermode=DImode, byte=0)
    at /home/richard/src/trunk/gcc/simplify-rtx.c:4956
4956	  gcc_assert (GET_MODE (op) == innermode

#3  0x081feadf in operand_subword (op=0xb7d50d2c, offset=0, 
    validate_address=1, mode=DImode)
    at /home/richard/src/trunk/gcc/emit-rtl.c:1399
1399	  return simplify_gen_subreg (word_mode, op, mode, (offset * UNITS_PER_WORD));
(gdb) call debug_rtx (op)
(subreg:SI (reg/v:DI 58 [ p_79.30 ]) 0)
(gdb) print word_mode
$2 = SImode
(gdb) print mode
$3 = DImode

from expanding

(int) p_79.30 & 1

with a wrong type on the BIT_AND_EXPR (long long, DImode).  Sounds familiar
somehow ...

Generated by PRE

  D.2018_117 = (int) p_79_115;
  pretmp.18_43 = D.2018_117 & 1;

pretmp.18_43 is long long, D.2018_117 is int.  Probably a wrong typed
constant in

# p_79_115 = PHI <1(3), 0(9)>


I will have a closer look.
Comment 3 Richard Biener 2008-09-18 13:49:42 UTC
The problem is that

  int64_t p1;
  int p;

  p1 = PHI <1, 0>
  p = PHI <1, 0>

are value-numbered the same.  I have a patch.
Comment 4 Richard Biener 2008-09-18 15:28:45 UTC
Subject: Bug 37258

Author: rguenth
Date: Thu Sep 18 15:27:21 2008
New Revision: 140460

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140460
Log:
2008-09-18  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/37258
	* tree-ssa-sccvn.c (vn_phi_compute_hash): Include the precision
	and signedness for integral types.
	(vn_phi_eq): Require compatible types.

	* gcc.c-torture/compile/pr37258.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr37258.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-sccvn.c

Comment 5 Richard Biener 2008-09-18 15:46:17 UTC
Fixed.