Bug 47140 - [4.6 Regression] error: conversion of register to a different size
Summary: [4.6 Regression] error: conversion of register to a different size
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: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2011-01-01 01:36 UTC by John Regehr
Modified: 2011-01-02 17:24 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.5.2
Known to fail: 4.6.0
Last reconfirmed: 2011-01-01 14:33:23


Attachments
gcc46-pr47140.patch (623 bytes, patch)
2011-01-01 15:26 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2011-01-01 01:36:11 UTC
There are several verify_stmts failed problems pending, but this one looks different.  Apologies if it's a dup.


[regehr@gamow tmp434]$ current-gcc -c -O2 small.c

small.c: In function 'uint321':
small.c:33:5: error: conversion of register to a different size
VIEW_CONVERT_EXPR<int>(D.2762_32);

pretmp.6_33 = VIEW_CONVERT_EXPR<int>(D.2762_32);

small.c:33:5: internal compiler error: verify_stmts failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

[regehr@gamow tmp434]$ current-gcc -v

Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r168380-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-r168380-install --program-prefix=r168380- --enable-languages=c,c++
Thread model: posix
gcc version 4.6.0 20101231 (experimental) (GCC) 

[regehr@gamow tmp434]$ cat small.c

typedef short int int16_t;
typedef int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;

static int32_t
safe_mod_func_int32_t_s_s (int32_t si1, int16_t si2)
{
  return si2 == 0 || si1 == -2147483647 - 1 && si2 ? si1 : si1 + si2;
}

static uint8_t
safe_add_func_uint8_t_u_u (uint8_t ui1, uint8_t ui2)
{
  return ui1 + ui2;
}

static uint16_t
safe_sub_func_uint16_t_u_u (uint16_t ui1, uint8_t ui2)
{
  return ui1 - ui2;
}

int16_t g_32;
int16_t g_76[7][10] = {
};

volatile int32_t g_98[1][1] = {
};

volatile int32_t *g_97 = &g_98[0][0];

int uint321 (void)
{
  for (0;; 1)
    *g_97 =
      safe_mod_func_int32_t_s_s (safe_add_func_uint8_t_u_u
				 (1,
				  func_21 (g_32,
					   g_76[5][5])) >=
				 safe_sub_func_uint16_t_u_u (&g_97 == 0, 1),
				 0);
}
Comment 1 Jakub Jelinek 2011-01-01 14:33:23 UTC
Caused by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162943
Smaller testcase:
static int
foo (int x, short y)
{
  return y == 0 ? x : x + y;
}

static unsigned short
bar (unsigned short x, unsigned char y)
{
  return x - y;
}

int w;

int baz (void);

int
test (void)
{
  for (;;)
    w = foo ((unsigned char) (1 + baz ()) >= bar (0, 1), 0);
}
Comment 2 Jakub Jelinek 2011-01-01 15:26:01 UTC
Created attachment 22877 [details]
gcc46-pr47140.patch

Untested fix.
Comment 3 Jakub Jelinek 2011-01-02 17:09:11 UTC
Author: jakub
Date: Sun Jan  2 17:09:08 2011
New Revision: 168402

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168402
Log:
	PR tree-optimization/47140
	* tree-ssa-ccp.c (evaluate_stmt): For binary assignments, use
	TREE_TYPE (lhs) instead of TREE_TYPE (rhs1) as second argument
	to bit_value_binop.

	* gcc.c-torture/compile/pr47140.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr47140.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-ccp.c
Comment 4 Jakub Jelinek 2011-01-02 17:24:32 UTC
Fixed.