public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/48734] New: ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321
@ 2011-04-22 20:53 regehr at cs dot utah.edu
  2011-04-26  6:16 ` [Bug tree-optimization/48734] [4.6/4.7 Regression] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: regehr at cs dot utah.edu @ 2011-04-22 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: ICE in eliminate_redundant_comparison, at
                    tree-ssa-reassoc.c:1321
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: regehr@cs.utah.edu
                CC: chenyang@cs.utah.edu
              Host: x86_64-unknown-linux-gnu
            Target: x86_64-unknown-linux-gnu
             Build: x86_64-unknown-linux-gnu


[regehr@gamow tmp013]$ current-gcc -O3 small.c
small.c: In function 'func_69':
small.c:12:1: internal compiler error: in eliminate_redundant_comparison, at
tree-ssa-reassoc.c:1321
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
[regehr@gamow tmp013]$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r172870-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.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-r172870-install
--program-prefix=r172870- --enable-languages=c,c++
Thread model: posix
gcc version 4.7.0 20110422 (experimental) (GCC) 
[regehr@gamow tmp013]$ cat small.c
int
safe_21 (int si)
{
  return si == -2147483647 - 1 ? si : -si;
}

unsigned g_73;
unsigned g_79;
long g_178;
int g_709;
int *
func_69 (p_71)
{
  long l_78 = 1;
  int i;
  for (i = 0; l_78 < 10; l_78 += 1)
    for (g_79 = 0; g_79 < 1; g_79 = 1)
      g_178 &= safe_21 (p_71) > g_73;
  return 0;
}

void
func_60 (unsigned p_61, int *p_62, int *p_64)
{
  func_69 (p_61);
}

int
main (void)
{
  int *l_858 = &g_709;
  int i;
  for (i = 0; i < 1; g_73 = 1)
    for (; i < 1; i++)
      {
      }
  long l_857 = 1;
  func_60 (l_857, l_858, &g_709);
  func_60 (0, 0, 0);
  return 0;
}


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

* [Bug tree-optimization/48734] [4.6/4.7 Regression] ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321
  2011-04-22 20:53 [Bug c/48734] New: ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321 regehr at cs dot utah.edu
@ 2011-04-26  6:16 ` jakub at gcc dot gnu.org
  2011-04-26  6:57 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-26  6:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.04.26 06:14:36
          Component|c                           |tree-optimization
                 CC|                            |jakub at gcc dot gnu.org
     Ever Confirmed|0                           |1
            Summary|ICE in                      |[4.6/4.7 Regression] ICE in
                   |eliminate_redundant_compari |eliminate_redundant_compari
                   |son, at                     |son, at
                   |tree-ssa-reassoc.c:1321     |tree-ssa-reassoc.c:1321
   Target Milestone|---                         |4.6.1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-26 06:14:36 UTC ---
Related to PR45059, caused by
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159189


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

* [Bug tree-optimization/48734] [4.6/4.7 Regression] ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321
  2011-04-22 20:53 [Bug c/48734] New: ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321 regehr at cs dot utah.edu
  2011-04-26  6:16 ` [Bug tree-optimization/48734] [4.6/4.7 Regression] " jakub at gcc dot gnu.org
@ 2011-04-26  6:57 ` jakub at gcc dot gnu.org
  2011-04-26  7:39 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-26  6:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-26 06:56:46 UTC ---
Reduced testcase:

unsigned int
foo (int x, unsigned int y, unsigned int z)
{
  z &= (x == -__INT_MAX__ - 1 ? x : -x) > y;
  z &= (x == -__INT_MAX__ - 1 ? x : -x) > y;
  z &= (x == -__INT_MAX__ - 1 ? x : -x) > y;
  return z;
}

The problem is that fold (from maybe_fold_and_comparisons) in this case
canonicalizes the comparison in:
                /* The following case also applies to X < signed_max+1
                   and X >= signed_max+1 because previous transformations.  */
                if (code == LE_EXPR || code == GT_EXPR)
                  {
                    tree st;
                    st = signed_type_for (TREE_TYPE (arg1));   
                    return fold_build2_loc (loc,
                                        code == LE_EXPR ? GE_EXPR : LT_EXPR,
                                        type, fold_convert_loc (loc, st, arg0),
                                        build_int_cst (st, 0));
                  }
to include the extra cast to the signed cast and eliminate_redundant_comparison
is prepared to handle just one operation instead of two.  I think expecting
fold to return some particular form of result is just wrong assumption, it will
break sooner or later, so while the code could perhaps handle on extra cast or
something similar, it needs to give up on elimination if the returned
expression can't be handled.


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

* [Bug tree-optimization/48734] [4.6/4.7 Regression] ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321
  2011-04-22 20:53 [Bug c/48734] New: ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321 regehr at cs dot utah.edu
  2011-04-26  6:16 ` [Bug tree-optimization/48734] [4.6/4.7 Regression] " jakub at gcc dot gnu.org
  2011-04-26  6:57 ` jakub at gcc dot gnu.org
@ 2011-04-26  7:39 ` jakub at gcc dot gnu.org
  2011-04-26 12:17 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-26  7:39 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-26 07:37:58 UTC ---
Created attachment 24099
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24099
gcc46-pr48734.patch

Untested fix.


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

* [Bug tree-optimization/48734] [4.6/4.7 Regression] ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321
  2011-04-22 20:53 [Bug c/48734] New: ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321 regehr at cs dot utah.edu
                   ` (2 preceding siblings ...)
  2011-04-26  7:39 ` jakub at gcc dot gnu.org
@ 2011-04-26 12:17 ` rguenth at gcc dot gnu.org
  2011-04-26 13:37 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-26 12:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-26 12:15:13 UTC ---
Looks good to me.


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

* [Bug tree-optimization/48734] [4.6/4.7 Regression] ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321
  2011-04-22 20:53 [Bug c/48734] New: ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321 regehr at cs dot utah.edu
                   ` (3 preceding siblings ...)
  2011-04-26 12:17 ` rguenth at gcc dot gnu.org
@ 2011-04-26 13:37 ` jakub at gcc dot gnu.org
  2011-04-26 13:46 ` jakub at gcc dot gnu.org
  2011-04-26 13:50 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-26 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-26 13:33:55 UTC ---
Author: jakub
Date: Tue Apr 26 13:33:49 2011
New Revision: 172967

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172967
Log:
    PR tree-optimization/48734
    * tree-ssa-reassoc.c (eliminate_redundant_comparison): Give up
    if return value from maybe_fold_*_comparsions isn't something
    the code is prepared to handle.

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

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr48734.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-reassoc.c


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

* [Bug tree-optimization/48734] [4.6/4.7 Regression] ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321
  2011-04-22 20:53 [Bug c/48734] New: ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321 regehr at cs dot utah.edu
                   ` (4 preceding siblings ...)
  2011-04-26 13:37 ` jakub at gcc dot gnu.org
@ 2011-04-26 13:46 ` jakub at gcc dot gnu.org
  2011-04-26 13:50 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-26 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-26 13:44:54 UTC ---
Author: jakub
Date: Tue Apr 26 13:44:51 2011
New Revision: 172969

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172969
Log:
    PR tree-optimization/48734
    * tree-ssa-reassoc.c (eliminate_redundant_comparison): Give up
    if return value from maybe_fold_*_comparsions isn't something
    the code is prepared to handle.

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

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.c-torture/compile/pr48734.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-ssa-reassoc.c


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

* [Bug tree-optimization/48734] [4.6/4.7 Regression] ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321
  2011-04-22 20:53 [Bug c/48734] New: ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321 regehr at cs dot utah.edu
                   ` (5 preceding siblings ...)
  2011-04-26 13:46 ` jakub at gcc dot gnu.org
@ 2011-04-26 13:50 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-26 13:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-26 13:48:10 UTC ---
Fixed.


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

end of thread, other threads:[~2011-04-26 13:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-22 20:53 [Bug c/48734] New: ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321 regehr at cs dot utah.edu
2011-04-26  6:16 ` [Bug tree-optimization/48734] [4.6/4.7 Regression] " jakub at gcc dot gnu.org
2011-04-26  6:57 ` jakub at gcc dot gnu.org
2011-04-26  7:39 ` jakub at gcc dot gnu.org
2011-04-26 12:17 ` rguenth at gcc dot gnu.org
2011-04-26 13:37 ` jakub at gcc dot gnu.org
2011-04-26 13:46 ` jakub at gcc dot gnu.org
2011-04-26 13:50 ` jakub at gcc dot gnu.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).