Bug 7277 - Casting integers to vector types causes internal compiler error
Summary: Casting integers to vector types causes internal compiler error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: 3.3.2
Assignee: Aldy Hernandez
URL:
Keywords: ice-on-valid-code, monitored
: 9572 10963 11215 (view as bug list)
Depends on:
Blocks: 8869
  Show dependency treegraph
 
Reported: 2002-07-11 07:06 UTC by hakonrk
Modified: 2003-09-15 15:20 UTC (History)
6 users (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-18 22:12:50


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hakonrk 2002-07-11 07:06:00 UTC
Casting integers into vector types (of the same size) causes
internal compiler errors.  The following illustrates what happens
when casting from a constant integer (code shown in How-To-Repeat):

##############################################################################
$ gcc -v -c -mmmx cast.c
Reading specs from /usr/local/gcc-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: /local/build/gcc/gcc-3.1/configure --prefix=/usr/local/gcc-3.1 --enable-languages=c --disable-nls
Thread model: single
gcc version 3.1
 /usr/local/gcc-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ cast.c -quiet -dumpbase cast.c -mmmx -version -o /tmp/cc2ubmWE.s
GNU CPP version 3.1 (cpplib) (i386 Linux/ELF)
GNU C version 3.1 (i686-pc-linux-gnu)
	compiled by GNU C version 3.1.
ignoring nonexistent directory "/usr/local/gcc-3.1/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/gcc-3.1/include
 /usr/local/gcc-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
 /usr/include
End of search list.
cast.c: In function `null':
cast.c:6: Internal compiler error in output_constant_pool, at varasm.c:4064
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
##############################################################################

When casting from a non-volatile variable, a new ICE appears if
and only if optimization is enabled:

Internal compiler error in subst, at combine.c:3546

This ICE will also manifest itself if one tries to trick the
compiler by using a union of "long long" and "v8qi", assigning
to the "long long" variable and returning the "v8qi" variable.
Again, the ICE only appears when optimization is enabled.

Release:
3.1

Environment:
System: Linux s 2.4.18 #2 Thu Jun 6 00:23:32 CEST 2002 i686 unknown
Distribution: Slackware 8.1
Architecture: i686

host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /local/build/gcc/gcc-3.1/configure --prefix=/usr/local/gcc-3.1 --enable-languages=c --disable-nls

How-To-Repeat:
# 1 "cast.c"
typedef int v8qi __attribute__ ((mode(V8QI)));

v8qi null(void)
{
        return (v8qi) 0LL;
}
Comment 1 hakonrk 2002-07-11 07:06:00 UTC
Fix:
Work-around: Use a volatile temporary variable:

/****************************************************************************/
typedef int v8qi __attribute__ ((mode(V8QI)));

v8qi null(void)
{
	volatile long long tmp = 0LL;
        return (v8qi) tmp;
}
/****************************************************************************/
Comment 2 Andrew Pinski 2002-07-11 10:12:27 UTC
From: Andrew Pinski <pinskia@physics.uc.edu>
To: hakonrk@fys.uio.no
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/7277: Casting integers to vector types causes internal compiler error
Date: Thu, 11 Jul 2002 10:12:27 -0400

 This has been fixed in: gcc version 3.2 20020709 (experimental)
 
 Thanks,
 Andrew Pinski
 On Thursday, July 11, 2002, at 10:01 , hakonrk@fys.uio.no wrote:
 
 > typedef int v8qi __attribute__ ((mode(V8QI)));
 >
 > v8qi null(void)
 > {
 >         return (v8qi) 0LL;
 > }
 

Comment 3 Andrew Pinski 2002-07-11 11:34:50 UTC
From: Andrew Pinski <pinskia@physics.uc.edu>
To: Haakon Riiser <haakon.riiser@fys.uio.no>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/7277: Casting integers to vector types causes internal compiler error
Date: Thu, 11 Jul 2002 11:34:50 -0400

 I did not see the option, -mmmx, before sorry.
 Yes it is still causes an ice.
 
 Thanks,
 Andrew Pinski
 
 On Thursday, July 11, 2002, at 11:31 , Haakon Riiser wrote:
 
 > -mmmx
 
Comment 4 haakon.riiser 2002-07-11 17:31:45 UTC
From: Haakon Riiser <haakon.riiser@fys.uio.no>
To: Andrew Pinski <pinskia@physics.uc.edu>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/7277: Casting integers to vector types causes internal compiler error
Date: Thu, 11 Jul 2002 17:31:45 +0200

 [Andrew Pinski]
 
 >> # 1 "cast.c"
 >> typedef int v8qi __attribute__ ((mode(V8QI)));
 >>
 >> v8qi null(void)
 >> {
 >>        return (v8qi) 0LL;
 >> }
 
 > This has been fixed in: gcc version 3.2 20020709 (experimental)
 
 Really?  From gcc version 3.2 20020711 (experimental):
 
 ##############################################################################
 $ gcc -v -c -mmmx cast.c
 Reading specs from /mn/rom/u7/hakonrk/i386/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
 Configured with: /mn/rom/u7/hakonrk/local/susy/src/gcc-cvs/gcc/configure --prefix=/mn/rom/u7/hakonrk/i386/gcc-cvs --enable-languages=c --disable-nls
 Thread model: single
 gcc version 3.2 20020711 (experimental)
  /mn/rom/u7/hakonrk/i386/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.2/cc1 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 cast.c -quiet -dumpbase cast.c -mmmx -version -o /tmp/ccJDF0nv.s
 GNU C version 3.2 20020711 (experimental) (i686-pc-linux-gnu)
 	compiled by GNU C version 3.2 20020711 (experimental).
 ignoring nonexistent directory "/mn/rom/u7/hakonrk/i386/gcc-cvs/i686-pc-linux-gnu/include"
 #include "..." search starts here:
 #include <...> search starts here:
  /usr/local/include
  /mn/rom/u7/hakonrk/i386/gcc-cvs/include
  /mn/rom/u7/hakonrk/i386/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.2/include
  /usr/include
 End of search list.
 cast.c: In function `null':
 cast.c:6: internal compiler error: Internal compiler error in output_constant_pool, at varasm.c:3465
 Please submit a full bug report,
 with preprocessed source if appropriate.
 See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
 ##############################################################################
 
 Same thing, except that the line number in varasm.c has changed from
 4064 to 3465.
 
 -- 
  Haakon

Comment 5 Volker Reichelt 2002-11-29 04:02:45 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.
    Still crashes 3.2-branch and mainline.
Comment 6 Andrew Pinski 2003-04-02 00:12:43 UTC
From: Andrew Pinski <pinskia@physics.uc.edu>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org,
   gcc-prs@gcc.gnu.org, hakonrk@fys.uio.no
Cc: Andrew Pinski <pinskia@physics.uc.edu>
Subject: Re: c/7277: Casting integers to vector types causes internal compiler error
Date: Wed, 2 Apr 2003 00:12:43 -0500

 Still fails on the mainline:
 ===========================
 Starting program:  
 /home/gates/pinskia/linux/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1 -quiet  
 -v cast.c -quiet -dumpbase cast.c -mmmx -auxbase cast -version -o  
 /tmp/ccejuWIv.s
 #include "..." search starts here:
 #include <...> search starts here:
   /usr/local/include
   /home/gates/pinskia/linux/include
   /home/gates/pinskia/linux/lib/gcc-lib/i686-pc-linux-gnu/3.4/include
   /home/gates/pinskia/linux/i686-pc-linux-gnu/include
   /usr/include
 End of search list.
 GNU C version 3.4 20030401 (experimental) (i686-pc-linux-gnu)
          compiled by GNU C version 3.4 20030401 (experimental).
 GGC heuristics: --param ggc-min-expand=98 --param  
 ggc-min-heapsize=128866
 cast.c: In function `null':
 cast.c:6: internal compiler error: in output_constant_pool, at  
 varasm.c:3457
 Please submit a full bug report,
 with preprocessed source if appropriate.
 See <URL:http://gcc.gnu.org/bugs.html> for instructions.
 ==========================
 a little more information:
 x at this point is a CONST_INT, not a CONST_VECTOR which is what is  
 expecting.
 
 Thanks,
 Andrew Pinski
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- 
 trail&database=gcc&pr=7277
Comment 7 Andrew Pinski 2003-06-02 14:29:06 UTC
*** Bug 10963 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2003-06-14 14:12:21 UTC
Still happens on the mainline (20030614).
Comment 9 Andrew Pinski 2003-06-17 02:17:26 UTC
*** Bug 9572 has been marked as a duplicate of this bug. ***
Comment 10 Andrew Pinski 2003-06-17 02:22:25 UTC
*** Bug 11215 has been marked as a duplicate of this bug. ***
Comment 11 Andrew Pinski 2003-08-23 21:55:36 UTC
Fixed on the mainline by a patch by Jan.
Comment 12 Volker Reichelt 2003-09-15 09:13:37 UTC
Now also fixed on the 3.3 branch (see PR 8869).