public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/32780]  New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
@ 2007-07-16 15:57 bero at arklinux dot org
  2007-07-16 15:58 ` [Bug c/32780] " bero at arklinux dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bero at arklinux dot org @ 2007-07-16 15:57 UTC (permalink / raw)
  To: gcc-bugs

gcc -DHAVE_CONFIG_H -I. -I../../../../include -I../../../../hw/xfree86
-I../../../../hw/xfree86/include -I../../../../hw/xfree86/common
-I../../../../hw/xfree86/os-support -I../../../../hw/xfree86/os-support/bus
-I../../../../os -I/usr/include/drm -DUSESTDRES -DHAVE_SYSV_IPC
-DHAVE_XORG_CONFIG_H -DXF86PM -DHAVE_ACPI -DHAVE_APM -Wall -Wpointer-arith
-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
-Wnested-externs -fno-strict-aliasing -D_BSD_SOURCE -DHAS_FCHOWN
-DHAS_STICKY_DIR_BIT -I/usr/include/freetype2 -I../../../../include
-I../../../../include -I../../../../Xext -I../../../../composite
-I../../../../damageext -I../../../../xfixes -I../../../../Xi -I../../../../mi
-I../../../../miext/shadow -I../../../../miext/damage -I../../../../render
-I../../../../randr -I../../../../fb -O2  -MT lnx_init.lo -MD -MP -MF
.deps/lnx_init.Tpo -c lnx_init.c  -fPIC -DPIC -o .libs/lnx_init.o
lnx_video.c: In function 'unmapVidMem':
lnx_video.c:516: internal compiler error: in extract_range_from_binary_expr, at
tree-vrp.c:1793
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


-- 
           Summary: ICE in extract_range_from_binary_expr, at tree-
                    vrp.c:1793 at -O2 or higher
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bero at arklinux dot org
 GCC build triplet: i586-pc-linux-gnu
  GCC host triplet: i586-pc-linux-gnu
GCC target triplet: i586-pc-linux-gnu


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


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

* [Bug c/32780] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
@ 2007-07-16 15:58 ` bero at arklinux dot org
  2007-07-16 16:13 ` bero at arklinux dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bero at arklinux dot org @ 2007-07-16 15:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bero at arklinux dot org  2007-07-16 15:58 -------
Created an attachment (id=13925)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13925&action=view)
preprocessed source


-- 


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


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

* [Bug c/32780] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
  2007-07-16 15:58 ` [Bug c/32780] " bero at arklinux dot org
@ 2007-07-16 16:13 ` bero at arklinux dot org
  2007-07-16 16:47 ` [Bug middle-end/32780] [4.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bero at arklinux dot org @ 2007-07-16 16:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bero at arklinux dot org  2007-07-16 16:13 -------
Simplified test case:

extern void dont_optimize_away(unsigned long);

void crashGcc(char*a)
{
        unsigned long b=(unsigned long)a - ((unsigned long)a & 1);
        dont_optimize_away(b);
}


-- 


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


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

* [Bug middle-end/32780] [4.3 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
  2007-07-16 15:58 ` [Bug c/32780] " bero at arklinux dot org
  2007-07-16 16:13 ` bero at arklinux dot org
@ 2007-07-16 16:47 ` pinskia at gcc dot gnu dot org
  2007-07-18 20:15 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-16 16:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2007-07-16 16:47 -------
This one is most likely my fault with pointer plus, something is creating an
BIT_AND_EXPR with a pointer type.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
            Summary|ICE in                      |[4.3 Regression] ICE in
                   |extract_range_from_binary_ex|extract_range_from_binary_ex
                   |pr, at tree-vrp.c:1793 at - |pr, at tree-vrp.c:1793 at -
                   |O2 or higher                |O2 or higher
   Target Milestone|---                         |4.3.0


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


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

* [Bug middle-end/32780] [4.3 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
                   ` (2 preceding siblings ...)
  2007-07-16 16:47 ` [Bug middle-end/32780] [4.3 Regression] " pinskia at gcc dot gnu dot org
@ 2007-07-18 20:15 ` pinskia at gcc dot gnu dot org
  2007-07-18 20:19 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-18 20:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-07-18 20:15 -------
This patch adds extra testing (though not tested fully) to catch this earlier:
Index: tree.c
===================================================================
--- tree.c      (revision 126721)
+++ tree.c      (working copy)
@@ -3072,8 +3072,12 @@
   gcc_assert (code != GIMPLE_MODIFY_STMT);
 #endif

-  if ((code == MINUS_EXPR || code == PLUS_EXPR || code == MULT_EXPR)
-      && arg0 && arg1 && tt && POINTER_TYPE_P (tt))
+  if ((code == MINUS_EXPR || code == PLUS_EXPR || code == MULT_EXPR
+       || code == BIT_AND_EXPR)
+      && arg0 && arg1 && tt
+      && (POINTER_TYPE_P (tt)
+         || POINTER_TYPE_P (TREE_TYPE (arg1))
+         || POINTER_TYPE_P (TREE_TYPE (arg0))))
     gcc_assert (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) ==
INTEGER_CST);

   if (code == POINTER_PLUS_EXPR && arg0 && arg1 && tt)


-- 


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


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

* [Bug middle-end/32780] [4.3 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
                   ` (3 preceding siblings ...)
  2007-07-18 20:15 ` pinskia at gcc dot gnu dot org
@ 2007-07-18 20:19 ` pinskia at gcc dot gnu dot org
  2007-07-18 20:20 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-18 20:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2007-07-18 20:19 -------
Confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-07-18 20:19:24
               date|                            |


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


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

* [Bug middle-end/32780] [4.3 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
                   ` (4 preceding siblings ...)
  2007-07-18 20:19 ` pinskia at gcc dot gnu dot org
@ 2007-07-18 20:20 ` pinskia at gcc dot gnu dot org
  2007-08-04  0:44 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-18 20:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2007-07-18 20:20 -------
Here is a patch which fixes this specific ICE:
Index: fold-const.c
===================================================================
--- fold-const.c        (revision 126721)
+++ fold-const.c        (working copy)
@@ -9723,15 +9723,19 @@
              && TREE_CODE (arg1) == BIT_AND_EXPR)
            {
              if (operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0))
-               return fold_build2 (BIT_AND_EXPR, type,
-                                   fold_build1 (BIT_NOT_EXPR, type,
-                                                TREE_OPERAND (arg1, 0)),
+               {
+                 tree arg10 = fold_convert (type, TREE_OPERAND (arg1, 0));
+                 return fold_build2 (BIT_AND_EXPR, type,
+                                   fold_build1 (BIT_NOT_EXPR, type, arg10),
                                    arg0);
+               }
              if (operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
-               return fold_build2 (BIT_AND_EXPR, type,
-                                   fold_build1 (BIT_NOT_EXPR, type,
-                                                TREE_OPERAND (arg1, 1)),
+               {
+                 tree arg11 = fold_convert (type, TREE_OPERAND (arg1, 1));
+                 return fold_build2 (BIT_AND_EXPR, type,
+                                   fold_build1 (BIT_NOT_EXPR, type, arg11),
                                    arg0);
+               }
            }

          /* Fold (A & ~B) - (A & B) into (A ^ B) - B, where B is


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


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


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

* [Bug middle-end/32780] [4.3 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
                   ` (5 preceding siblings ...)
  2007-07-18 20:20 ` pinskia at gcc dot gnu dot org
@ 2007-08-04  0:44 ` pinskia at gcc dot gnu dot org
  2007-08-04  1:17 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-08-04  0:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2007-08-04 00:43 -------
Note with mismatch checking turned on (which is done by default at stage1), we
get a different ICE (which is not related to the changes done by pointer plus:
t.c: In function 'crashGcc':
t.c:6: error: type mismatch in binary expression
long unsigned int

char *

long unsigned int

b = a & 4294967294


-- 


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


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

* [Bug middle-end/32780] [4.3 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
                   ` (6 preceding siblings ...)
  2007-08-04  0:44 ` pinskia at gcc dot gnu dot org
@ 2007-08-04  1:17 ` pinskia at gcc dot gnu dot org
  2007-08-04  5:21 ` pinskia at gcc dot gnu dot org
  2007-08-04  5:22 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-08-04  1:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2007-08-04 01:17 -------
Here is a full patch which fixes the type mismatch type ICE also:
Index: fold-const.c
===================================================================
--- ../../gcc/fold-const.c      (revision 127190)
+++ ../../gcc/fold-const.c      (working copy)
@@ -9730,15 +9730,19 @@ fold_binary (enum tree_code code, tree t
              && TREE_CODE (arg1) == BIT_AND_EXPR)
            {
              if (operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0))
-               return fold_build2 (BIT_AND_EXPR, type,
-                                   fold_build1 (BIT_NOT_EXPR, type,
-                                                TREE_OPERAND (arg1, 0)),
-                                   arg0);
+               {
+                 tree arg10 = fold_convert (type, TREE_OPERAND (arg1, 0));
+                 return fold_build2 (BIT_AND_EXPR, type,
+                                     fold_build1 (BIT_NOT_EXPR, type, arg10),
+                                     fold_convert (type, arg0));
+               }
              if (operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
-               return fold_build2 (BIT_AND_EXPR, type,
-                                   fold_build1 (BIT_NOT_EXPR, type,
-                                                TREE_OPERAND (arg1, 1)),
-                                   arg0);
+               {
+                 tree arg11 = fold_convert (type, TREE_OPERAND (arg1, 1));
+                 return fold_build2 (BIT_AND_EXPR, type,
+                                     fold_build1 (BIT_NOT_EXPR, type, arg11),
+                                     fold_convert (type, arg0));
+               }
            }

          /* Fold (A & ~B) - (A & B) into (A ^ B) - B, where B is


-- 


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


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

* [Bug middle-end/32780] [4.3 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
                   ` (7 preceding siblings ...)
  2007-08-04  1:17 ` pinskia at gcc dot gnu dot org
@ 2007-08-04  5:21 ` pinskia at gcc dot gnu dot org
  2007-08-04  5:22 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-08-04  5:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2007-08-04 05:21 -------
Subject: Bug 32780

Author: pinskia
Date: Sat Aug  4 05:21:30 2007
New Revision: 127199

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127199
Log:

2007-08-04  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/32780
        * fold-const.c (fold_binary <case MINUS_EXPR>): Fix the type of
operands
        for the folding of "A - (A & B)" into "~B & A"; cast them to type.

2007-08-04  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/32780
        * gcc.c-torture/compile/pr32780.c: New test.


Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr32780.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/32780] [4.3 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher
  2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
                   ` (8 preceding siblings ...)
  2007-08-04  5:21 ` pinskia at gcc dot gnu dot org
@ 2007-08-04  5:22 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-08-04  5:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pinskia at gcc dot gnu dot org  2007-08-04 05:22 -------
Fixed.


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-08-04  5:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-16 15:57 [Bug c/32780] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:1793 at -O2 or higher bero at arklinux dot org
2007-07-16 15:58 ` [Bug c/32780] " bero at arklinux dot org
2007-07-16 16:13 ` bero at arklinux dot org
2007-07-16 16:47 ` [Bug middle-end/32780] [4.3 Regression] " pinskia at gcc dot gnu dot org
2007-07-18 20:15 ` pinskia at gcc dot gnu dot org
2007-07-18 20:19 ` pinskia at gcc dot gnu dot org
2007-07-18 20:20 ` pinskia at gcc dot gnu dot org
2007-08-04  0:44 ` pinskia at gcc dot gnu dot org
2007-08-04  1:17 ` pinskia at gcc dot gnu dot org
2007-08-04  5:21 ` pinskia at gcc dot gnu dot org
2007-08-04  5:22 ` 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).