public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17036] New: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int
@ 2004-08-15 16:55 bommar33 at msu dot edu
  2004-08-15 16:57 ` [Bug c/17036] " bommar33 at msu dot edu
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: bommar33 at msu dot edu @ 2004-08-15 16:55 UTC (permalink / raw)
  To: gcc-bugs

The error is easily reproducible outside of the conditions of the kernel code,
and, as I'm sure you'd appreciate, I have written an example that successfully
duplicates the exact ICE as below.  Attached is the significantly smaller
preprocessed example, compressed at 3k, in lieu of the 46k compressed kernel
driver :)  

System: i686-pc-linux-gnu (Fedora 2 release, kernel 2.6.7-1.494.2.2, athlon-xp
1800+)

GCC Version: 3.5.0 20040801 (experimental)

GCC ./configure Options: --enable-threads --with-cpu=athlon-xp
--with-arch=athlon-xp --enable-languages=c,c++

Command: 
[root@epithumadze linux-2.6.8]# make modules V=1
...
make -f scripts/Makefile.build obj=sound/synth/emux

gcc -Wp,-MD,sound/synth/emux/.emux_oss.o.d -nostdinc -iwithprefix include
-D__KERNEL__ -Iinclude  -Wall -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -pipe -msoft-float -mpreferred-stack-boundary=2
-fno-unit-at-a-time -march=athlon -mregparm=3 -Iinclude/asm-i386/mach-default
-O2 -fomit-frame-pointer -Wdeclaration-after-statement   -DMODULE
-DKBUILD_BASENAME=emux_oss -DKBUILD_MODNAME=snd_emux_synth -c -o
sound/synth/emux/emux_oss.o sound/synth/emux/emux_oss.c

Compiler Output:
sound/synth/emux/emux_oss.c: In function `emuspec_control':
sound/synth/emux/emux_oss.c:400: internal compiler error: tree check: expected
integer_cst, have var_decl in fold, at fold-const.c:8855

-- 
           Summary: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type
                    unsigned int
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bommar33 at msu dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17036


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/17036] ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int
  2004-08-15 16:55 [Bug c/17036] New: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int bommar33 at msu dot edu
@ 2004-08-15 16:57 ` bommar33 at msu dot edu
  2004-08-15 17:05 ` [Bug middle-end/17036] [3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: bommar33 at msu dot edu @ 2004-08-15 16:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bommar33 at msu dot edu  2004-08-15 16:57 -------
Created an attachment (id=6932)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6932&action=view)
Preprocessed bug example source


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17036


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/17036] [3.5 Regression] ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int
  2004-08-15 16:55 [Bug c/17036] New: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int bommar33 at msu dot edu
  2004-08-15 16:57 ` [Bug c/17036] " bommar33 at msu dot edu
@ 2004-08-15 17:05 ` pinskia at gcc dot gnu dot org
  2004-08-15 18:05   ` Graham Stott
  2004-08-15 18:05 ` graham dot stott at btinternet dot com
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-15 17:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-15 17:05 -------
Confirmed
: Search converges between 2004-06-20-trunk (#469) and 2004-06-22-trunk (#470).
Reduced to:
int main( int argc, char **arg )
{
 int R , N = 4;
 unsigned int A = 2;
 signed int B = 2;
 ((B >> N) & 1) ? 1 : 0;
 ((A >> N) & 1) ? 1 : 0;
 return 0;
}


Looks like someone forgets to check to make sure that the N is really a constant.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bonzini at gnu dot org
           Severity|normal                      |critical
             Status|UNCONFIRMED                 |NEW
          Component|c                           |middle-end
     Ever Confirmed|                            |1
           Keywords|                            |ice-on-valid-code
      Known to fail|                            |3.5.0
      Known to work|                            |3.4.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-08-15 17:05:37
               date|                            |
            Summary|ICE: (A >> N) & 1 ? (1 << N)|[3.5 Regression] ICE: (A >>
                   |: 0 where A of type unsigned|N) & 1 ? (1 << N) : 0 where
                   |int                         |A of type unsigned int
   Target Milestone|---                         |3.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17036


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Bug middle-end/17036] [3.5 Regression] ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int
  2004-08-15 17:05 ` [Bug middle-end/17036] [3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-08-15 18:05   ` Graham Stott
  0 siblings, 0 replies; 9+ messages in thread
From: Graham Stott @ 2004-08-15 18:05 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs

pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-15 17:05 -------
> Confirmed
> : Search converges between 2004-06-20-trunk (#469) and 2004-06-22-trunk (#470).
> Reduced to:
> int main( int argc, char **arg )
> {
>  int R , N = 4;
>  unsigned int A = 2;
>  signed int B = 2;
>  ((B >> N) & 1) ? 1 : 0;
>  ((A >> N) & 1) ? 1 : 0;
>  return 0;
> }
> 
> 
> Looks like someone forgets to check to make sure that the N is really a constant.
> 

This patch should fixit but I don't have time to do a full bootstrap and
regression test on the patch.

-------------------------------------------------------------------
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.435
diff -c -p -r1.435 fold-const.c
*** fold-const.c        12 Aug 2004 04:01:04 -0000      1.435
--- fold-const.c        15 Aug 2004 17:53:10 -0000
*************** fold (tree expr)
*** 8874,8879 ****
--- 8874,8880 ----
           tree tem = TREE_OPERAND (arg0, 0);
           STRIP_NOPS (tem);
           if (TREE_CODE (tem) == RSHIFT_EXPR
+             && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
                 && (unsigned HOST_WIDE_INT) tree_log2 (arg1) ==
                  TREE_INT_CST_LOW (TREE_OPERAND (tem, 1)))
             return fold (build2 (BIT_AND_EXPR, type,
-------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/17036] [3.5 Regression] ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int
  2004-08-15 16:55 [Bug c/17036] New: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int bommar33 at msu dot edu
  2004-08-15 16:57 ` [Bug c/17036] " bommar33 at msu dot edu
  2004-08-15 17:05 ` [Bug middle-end/17036] [3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-08-15 18:05 ` graham dot stott at btinternet dot com
  2004-08-15 18:57 ` bommar33 at msu dot edu
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: graham dot stott at btinternet dot com @ 2004-08-15 18:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From graham dot stott at btinternet dot com  2004-08-15 18:05 -------
Subject: Re:  [3.5 Regression] ICE: (A >> N) & 1 ? (1
 << N) : 0 where A of type unsigned int

pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-15 17:05 -------
> Confirmed
> : Search converges between 2004-06-20-trunk (#469) and 2004-06-22-trunk (#470).
> Reduced to:
> int main( int argc, char **arg )
> {
>  int R , N = 4;
>  unsigned int A = 2;
>  signed int B = 2;
>  ((B >> N) & 1) ? 1 : 0;
>  ((A >> N) & 1) ? 1 : 0;
>  return 0;
> }
> 
> 
> Looks like someone forgets to check to make sure that the N is really a constant.
> 

This patch should fixit but I don't have time to do a full bootstrap and
regression test on the patch.

-------------------------------------------------------------------
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.435
diff -c -p -r1.435 fold-const.c
*** fold-const.c        12 Aug 2004 04:01:04 -0000      1.435
--- fold-const.c        15 Aug 2004 17:53:10 -0000
*************** fold (tree expr)
*** 8874,8879 ****
--- 8874,8880 ----
           tree tem = TREE_OPERAND (arg0, 0);
           STRIP_NOPS (tem);
           if (TREE_CODE (tem) == RSHIFT_EXPR
+             && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
                 && (unsigned HOST_WIDE_INT) tree_log2 (arg1) ==
                  TREE_INT_CST_LOW (TREE_OPERAND (tem, 1)))
             return fold (build2 (BIT_AND_EXPR, type,
-------------------------------------------------------------------


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17036


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/17036] [3.5 Regression] ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int
  2004-08-15 16:55 [Bug c/17036] New: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int bommar33 at msu dot edu
                   ` (2 preceding siblings ...)
  2004-08-15 18:05 ` graham dot stott at btinternet dot com
@ 2004-08-15 18:57 ` bommar33 at msu dot edu
  2004-08-16  7:19 ` paolo dot bonzini at polimi dot it
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: bommar33 at msu dot edu @ 2004-08-15 18:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bommar33 at msu dot edu  2004-08-15 18:57 -------
> This patch should fixit but I don't have time to do a full bootstrap and
> regression test on the patch.
> 
> -------------------------------------------------------------------
> Index: fold-const.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
> retrieving revision 1.435
> diff -c -p -r1.435 fold-const.c
> *** fold-const.c        12 Aug 2004 04:01:04 -0000      1.435
> --- fold-const.c        15 Aug 2004 17:53:10 -0000
> *************** fold (tree expr)
> *** 8874,8879 ****
> --- 8874,8880 ----
>            tree tem = TREE_OPERAND (arg0, 0);
>            STRIP_NOPS (tem);
>            if (TREE_CODE (tem) == RSHIFT_EXPR
> +             && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
>                  && (unsigned HOST_WIDE_INT) tree_log2 (arg1) ==
>                   TREE_INT_CST_LOW (TREE_OPERAND (tem, 1)))
>              return fold (build2 (BIT_AND_EXPR, type,
> -------------------------------------------------------------------
> 

When patched against the 20040801 tree that I had initially generated the error
on, it successfully recompiled and properly generated the code.  Thanks to both
of you for the quick response time :)

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17036


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/17036] [3.5 Regression] ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int
  2004-08-15 16:55 [Bug c/17036] New: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int bommar33 at msu dot edu
                   ` (3 preceding siblings ...)
  2004-08-15 18:57 ` bommar33 at msu dot edu
@ 2004-08-16  7:19 ` paolo dot bonzini at polimi dot it
  2004-08-17  7:40 ` cvs-commit at gcc dot gnu dot org
  2004-08-17  8:19 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 9+ messages in thread
From: paolo dot bonzini at polimi dot it @ 2004-08-16  7:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From paolo dot bonzini at polimi dot it  2004-08-16 07:19 -------
Subject: Re:  [3.5 Regression] ICE: (A >> N) & 1 ? (1
 << N) : 0 where A of type unsigned int

>>This patch should fixit but I don't have time to do a full bootstrap and
>>regression test on the patch.

Starting a bootstrap and regression test now, will commit as obvious if 
it succeeds.  Thanks for investigating this.

Paolo



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17036


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/17036] [3.5 Regression] ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int
  2004-08-15 16:55 [Bug c/17036] New: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int bommar33 at msu dot edu
                   ` (4 preceding siblings ...)
  2004-08-16  7:19 ` paolo dot bonzini at polimi dot it
@ 2004-08-17  7:40 ` cvs-commit at gcc dot gnu dot org
  2004-08-17  8:19 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-17  7:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-08-17 07:40 -------
Subject: Bug 17036

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bonzini@gcc.gnu.org	2004-08-17 07:40:23

Modified files:
	gcc            : ChangeLog fold-const.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: pr17036-1.c 

Log message:
	gcc/ChangeLog:
	2004-08-17  Paolo Bonzini  <bonzini@gnu.org>
	
	PR middle-end/17036
	* fold-const.c (fold): Check for integer operand when
	folding (A >> N) & 1 ? (1 << N) : 0.  Fix from Andrew
	Pinski  <pinskia@physics.uc.edu>.
	
	gcc/testsuite/ChangeLog:
	2004-08-17  Paolo Bonzini  <bonzini@gnu.org>
	
	* gcc.dg/pr17036-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4931&r2=2.4932
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.436&r2=1.437
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4145&r2=1.4146
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr17036-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17036


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/17036] [3.5 Regression] ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int
  2004-08-15 16:55 [Bug c/17036] New: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int bommar33 at msu dot edu
                   ` (5 preceding siblings ...)
  2004-08-17  7:40 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-17  8:19 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-17  8:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-17 08:19 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17036


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-08-17  8:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-15 16:55 [Bug c/17036] New: ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int bommar33 at msu dot edu
2004-08-15 16:57 ` [Bug c/17036] " bommar33 at msu dot edu
2004-08-15 17:05 ` [Bug middle-end/17036] [3.5 Regression] " pinskia at gcc dot gnu dot org
2004-08-15 18:05   ` Graham Stott
2004-08-15 18:05 ` graham dot stott at btinternet dot com
2004-08-15 18:57 ` bommar33 at msu dot edu
2004-08-16  7:19 ` paolo dot bonzini at polimi dot it
2004-08-17  7:40 ` cvs-commit at gcc dot gnu dot org
2004-08-17  8:19 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).