Summary: | [4.0 Regression] ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int | ||
---|---|---|---|
Product: | gcc | Reporter: | Michael Bommarito II <bommar33> |
Component: | middle-end | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | critical | CC: | bonzini, gcc-bugs, reichelt |
Priority: | P2 | Keywords: | ice-on-valid-code, monitored |
Version: | 4.0.0 | ||
Target Milestone: | 4.0.0 | ||
Host: | i686-pc-linux-gnu | Target: | i686-pc-linux-gnu |
Build: | i686-pc-linux-gnu | Known to work: | 3.4.0 |
Known to fail: | 4.0.0 | Last reconfirmed: | 2004-08-15 17:05:37 |
Attachments: | Preprocessed bug example source |
Description
Michael Bommarito II
2004-08-15 16:55:30 UTC
Created attachment 6932 [details]
Preprocessed bug example source
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. 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,
-------------------------------------------------------------------
> 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 :)
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
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 Fixed. |