public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/49189] New: [4.7 regression] infinite recursion in constant folder
@ 2011-05-27 10:57 ebotcazou at gcc dot gnu.org
  2011-05-27 10:59 ` [Bug middle-end/49189] " ebotcazou at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-05-27 10:57 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [4.7 regression] infinite recursion in constant folder
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ebotcazou@gcc.gnu.org
                CC: rguenther@suse.de


The patch

2011-05-26  Richard Guenther  <rguenther@suse.de>

    * fold-const.c (fold_unary_loc): Remove bogus code.

has introduced an infinite recursion in the constant folder for the Ada
testcase about to be attached.  No change after the fix for PR
middle-end/49177.


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

* [Bug middle-end/49189] [4.7 regression] infinite recursion in constant folder
  2011-05-27 10:57 [Bug middle-end/49189] New: [4.7 regression] infinite recursion in constant folder ebotcazou at gcc dot gnu.org
@ 2011-05-27 10:59 ` ebotcazou at gcc dot gnu.org
  2011-05-27 11:13 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-05-27 10:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-05-27 10:56:33 UTC ---
Created attachment 24367
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24367
Concatenated testcase

Run gnatchop on the file.  Suitable for inclusion in the gnat.dg testsuite.


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

* [Bug middle-end/49189] [4.7 regression] infinite recursion in constant folder
  2011-05-27 10:57 [Bug middle-end/49189] New: [4.7 regression] infinite recursion in constant folder ebotcazou at gcc dot gnu.org
  2011-05-27 10:59 ` [Bug middle-end/49189] " ebotcazou at gcc dot gnu.org
@ 2011-05-27 11:13 ` rguenth at gcc dot gnu.org
  2011-05-27 11:22 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-27 11:13 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.05.27 11:05:24
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
   Target Milestone|---                         |4.7.0
     Ever Confirmed|0                           |1

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-27 11:05:24 UTC ---
Confirmed.  Endlessly visiting


Breakpoint 6, fold_unary_loc (loc=0, code=TRUTH_NOT_EXPR, type=0x7ffff5b7e5e8, 
    op0=0x7ffff5b820a0) at /space/rguenther/src/svn/trunk/gcc/fold-const.c:7555
7555      enum tree_code_class kind = TREE_CODE_CLASS (code);
(gdb) call debug_generic_expr (op0)
(const boolean) ((boolean) ((system__unsigned_types__short_unsigned) v->OBJECT
>> (integer) i) & 1)

Breakpoint 6, fold_unary_loc (loc=0, code=NOP_EXPR, type=0x7ffff5b7e5e8, 
    op0=0x7ffff5b83000) at /space/rguenther/src/svn/trunk/gcc/fold-const.c:7555
7555      enum tree_code_class kind = TREE_CODE_CLASS (code);
(gdb) call debug_generic_expr (op0)
((boolean) ((system__unsigned_types__short_unsigned) v->OBJECT >> (integer) i)
& 1) == 0
(gdb) call debug_generic_expr (type)
const boolean

Breakpoint 7, fold_binary_loc (loc=0, code=EQ_EXPR, type=0x7ffff5b7e5e8, 
    op0=0x7ffff5b72e70, op1=0x7ffff7ee85e0)
    at /space/rguenther/src/svn/trunk/gcc/fold-const.c:9280
9280      enum tree_code_class kind = TREE_CODE_CLASS (code);
(gdb) call debug_generic_expr (op0)
(boolean) ((system__unsigned_types__short_unsigned) v->OBJECT >> (integer) i) &
1
(gdb) call debug_generic_expr (op1)
0

Breakpoint 6, fold_unary_loc (loc=0, code=NOP_EXPR, type=0x7ffff5b7e5e8, 
    op0=0x7ffff5b72e70) at /space/rguenther/src/svn/trunk/gcc/fold-const.c:7555
7555      enum tree_code_class kind = TREE_CODE_CLASS (code);
(gdb) call debug_generic_expr (op0)
(boolean) ((system__unsigned_types__short_unsigned) v->OBJECT >> (integer) i) &
1
(gdb) call debug_generic_expr (type)
const boolean

Breakpoint 6, fold_unary_loc (loc=0, code=TRUTH_NOT_EXPR, type=0x7ffff5b7e5e8, 
    op0=0x7ffff5b820c8) at /space/rguenther/src/svn/trunk/gcc/fold-const.c:7555
7555      enum tree_code_class kind = TREE_CODE_CLASS (code);
...


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

* [Bug middle-end/49189] [4.7 regression] infinite recursion in constant folder
  2011-05-27 10:57 [Bug middle-end/49189] New: [4.7 regression] infinite recursion in constant folder ebotcazou at gcc dot gnu.org
  2011-05-27 10:59 ` [Bug middle-end/49189] " ebotcazou at gcc dot gnu.org
  2011-05-27 11:13 ` rguenth at gcc dot gnu.org
@ 2011-05-27 11:22 ` rguenth at gcc dot gnu.org
  2011-05-27 11:59 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-27 11:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-27 11:13:11 UTC ---
fold_truth_not_expr canonicalizes !(A & 1) to (A & 1) == 0 but fold_binary
canonicalizes bool == 0 to !bool.  A recipie for recursion. 
fold_truth_not_expr
doesn't re-fold its result but its result is fold-converted to bool through
which we then end up in that latent cycle.


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

* [Bug middle-end/49189] [4.7 regression] infinite recursion in constant folder
  2011-05-27 10:57 [Bug middle-end/49189] New: [4.7 regression] infinite recursion in constant folder ebotcazou at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-05-27 11:22 ` rguenth at gcc dot gnu.org
@ 2011-05-27 11:59 ` rguenth at gcc dot gnu.org
  2011-05-27 13:15 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-27 11:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-27 11:21:09 UTC ---
The old code did not re-fold in

      /* If we have (type) (a CMP b) and type is an integral type, return
         new expression involving the new type.  */
      if (COMPARISON_CLASS_P (op0) && INTEGRAL_TYPE_P (type))
        return fold_build2_loc (loc, TREE_CODE (op0), type, TREE_OPERAND (op0,
0),
                            TREE_OPERAND (op0, 1));

for BOOLEAN_TYPE.

It could be argued that re-folding is never necessary here because the
comparison does not depend on the type of the boolean result it produces.

So I'll disable re-folding here.


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

* [Bug middle-end/49189] [4.7 regression] infinite recursion in constant folder
  2011-05-27 10:57 [Bug middle-end/49189] New: [4.7 regression] infinite recursion in constant folder ebotcazou at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-05-27 11:59 ` rguenth at gcc dot gnu.org
@ 2011-05-27 13:15 ` rguenth at gcc dot gnu.org
  2011-05-27 13:16 ` rguenth at gcc dot gnu.org
  2011-05-27 13:39 ` wschmidt at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-27 13:15 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

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

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-27 13:13:50 UTC ---
Fixed.


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

* [Bug middle-end/49189] [4.7 regression] infinite recursion in constant folder
  2011-05-27 10:57 [Bug middle-end/49189] New: [4.7 regression] infinite recursion in constant folder ebotcazou at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-05-27 13:15 ` rguenth at gcc dot gnu.org
@ 2011-05-27 13:16 ` rguenth at gcc dot gnu.org
  2011-05-27 13:39 ` wschmidt at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-27 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-27 13:13:34 UTC ---
Author: rguenth
Date: Fri May 27 13:13:28 2011
New Revision: 174330

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174330
Log:
2011-05-27  Richard Guenther  <rguenther@suse.de>

    PR middle-end/49189
    * fold-const.c (fold_unary_loc): Do not re-fold folding conversions
    of comparisons.

    * gnat.dg/bit_packed_array5.adb: New testcase.
    * gnat.dg/bit_packed_array5.ads: Likewise.

Added:
    trunk/gcc/testsuite/gnat.dg/bit_packed_array5.adb
    trunk/gcc/testsuite/gnat.dg/bit_packed_array5.ads
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug middle-end/49189] [4.7 regression] infinite recursion in constant folder
  2011-05-27 10:57 [Bug middle-end/49189] New: [4.7 regression] infinite recursion in constant folder ebotcazou at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2011-05-27 13:16 ` rguenth at gcc dot gnu.org
@ 2011-05-27 13:39 ` wschmidt at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2011-05-27 13:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2011-05-27 13:30:03 UTC ---
Author: wschmidt
Date: Fri May 27 13:29:57 2011
New Revision: 174331

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174331
Log:
Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog    (revision 174330)
+++ gcc/ChangeLog    (working copy)
@@ -1,3 +1,9 @@
+2011-05-27  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+    PR tree-optimization/49170
+    * tree-ssa-math-opts.c (execute_cse_sincos):  Add checks for
+    sincos or cexp.
+    
 2011-05-27  Richard Guenther  <rguenther@suse.de>

     PR middle-end/49189
Index: gcc/tree-ssa-math-opts.c
===================================================================
--- gcc/tree-ssa-math-opts.c    (revision 174330)
+++ gcc/tree-ssa-math-opts.c    (working copy)
@@ -1093,6 +1093,10 @@ execute_cse_sincos (void)
         CASE_FLT_FN (BUILT_IN_COS):
         CASE_FLT_FN (BUILT_IN_SIN):
         CASE_FLT_FN (BUILT_IN_CEXPI):
+          /* Make sure we have either sincos or cexp.  */
+          if (!TARGET_HAS_SINCOS && !TARGET_C99_FUNCTIONS)
+            break;
+
           arg = gimple_call_arg (stmt, 0);
           if (TREE_CODE (arg) == SSA_NAME)
             cfg_changed |= execute_cse_sincos_1 (arg);

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-math-opts.c


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

end of thread, other threads:[~2011-05-27 13:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27 10:57 [Bug middle-end/49189] New: [4.7 regression] infinite recursion in constant folder ebotcazou at gcc dot gnu.org
2011-05-27 10:59 ` [Bug middle-end/49189] " ebotcazou at gcc dot gnu.org
2011-05-27 11:13 ` rguenth at gcc dot gnu.org
2011-05-27 11:22 ` rguenth at gcc dot gnu.org
2011-05-27 11:59 ` rguenth at gcc dot gnu.org
2011-05-27 13:15 ` rguenth at gcc dot gnu.org
2011-05-27 13:16 ` rguenth at gcc dot gnu.org
2011-05-27 13:39 ` wschmidt 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).