[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2012-07-06 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

--- Comment #11 from Richard Guenther rguenth at gcc dot gnu.org 2012-07-06 
09:25:51 UTC ---
Author: rguenth
Date: Fri Jul  6 09:25:46 2012
New Revision: 189314

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=189314
Log:
2012-07-06  Richard Guenther  rguent...@suse.de

Backport from mainline
2012-03-30  Richard Guenther  rguent...@suse.de

PR middle-end/52786
* double-int.c (rshift_double): Remove not
needed cast.

2012-03-28  Richard Guenther  rguent...@suse.de

PR middle-end/50708
* double-int.h (rshift_double): Remove.
* double-int.c (lshift_double): Use absu_hwi to make count
positive.
(rshift_double): Make static, take unsigned count argument,
remove handling of negative count argument.
(double_int_rshift): Dispatch to lshift_double.

Modified:
branches/gcc-4_7-branch/gcc/ChangeLog
branches/gcc-4_7-branch/gcc/double-int.c
branches/gcc-4_7-branch/gcc/double-int.h


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2012-07-06 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

  Known to work||4.7.2
   Target Milestone|4.8.0   |4.7.2
  Known to fail||4.7.1

--- Comment #12 from Richard Guenther rguenth at gcc dot gnu.org 2012-07-06 
09:27:34 UTC ---
4.7.2 even.



[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2012-07-05 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED
   Target Milestone|--- |4.8.0

--- Comment #10 from Richard Guenther rguenth at gcc dot gnu.org 2012-07-05 
14:55:41 UTC ---
Anyway, fixed for 4.8.


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2012-03-29 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

--- Comment #8 from Richard Guenther rguenth at gcc dot gnu.org 2012-03-29 
08:27:16 UTC ---
Author: rguenth
Date: Thu Mar 29 08:27:04 2012
New Revision: 185951

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=185951
Log:
2012-03-29  Richard Guenther  rguent...@suse.de

PR middle-end/50708
* double-int.h (rshift_double): Remove.
* double-int.c (lshift_double): Use absu_hwi to make count
positive.
(rshift_double): Make static, take unsigned count argument,
remove handling of negative count argument.
(double_int_rshift): Dispatch to lshift_double.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/double-int.c
trunk/gcc/double-int.h


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2012-03-29 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

  Known to work||4.8.0

--- Comment #9 from Richard Guenther rguenth at gcc dot gnu.org 2012-03-29 
09:21:17 UTC ---
Fixed on trunk sofar.


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2012-03-28 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 CC||borut.razem at gmail dot
   ||com

--- Comment #6 from Richard Guenther rguenth at gcc dot gnu.org 2012-03-28 
14:23:40 UTC ---
*** Bug 52653 has been marked as a duplicate of this bug. ***


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2012-03-28 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|unassigned at gcc dot   |rguenth at gcc dot gnu.org
   |gnu.org |

--- Comment #7 from Richard Guenther rguenth at gcc dot gnu.org 2012-03-28 
14:24:15 UTC ---
Mine.


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2011-10-30 Thread mikpe at it dot uu.se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

--- Comment #5 from Mikael Pettersson mikpe at it dot uu.se 2011-10-30 
20:35:03 UTC ---
The regression started with r158372:
http://gcc.gnu.org/ml/gcc-cvs/2010-04/msg00478.html

Here's what seems to have happened:
1. Anatoly Sokolov suggested to add a bunch of double_int_ functions:
http://gcc.gnu.org/ml/gcc-patches/2010-04/msg00482.html.

2. Eric Botcazou replied about the added double_int_rshift (a wrapper around
rshift_double) that the comment about the COUNT parameter was wrong, and that
rshift_double requires it to be positive (double_int_rshift stated that a
negative COUNT turned it into a left-shift):
http://gcc.gnu.org/ml/gcc-patches/2010-04/msg00557.html.

3. In the final version of Anatoly's patch committed in r158360:
http://gcc.gnu.org/ml/gcc-cvs/2010-04/msg00466.html, the comment above
rshift_double was changed to allow a negative COUNT as meaning a left-shift. 
However, the code in rshift_double was not changed, and still assumed that
COUNT would be positive.

4. Richard Guenther followed up with a cleanup patch to move rshift_double and
other related functions from fold-const.c to double-int.c in r158372:
http://gcc.gnu.org/ml/gcc-cvs/2010-04/msg00478.html.  However, rshift_double
was not copied verbatim, as a check for a negative COUNT was added at the
beginning followed by a conditional call to lshift_double with -COUNT.  This
made the code consistent with the comment, but also caused the loop on HWI32
platforms.

I suspect that r158360 shouldn't have allowed for a negative COUNT to
rshift_double or double_int_rshift.  Removing the check for negative COUNT from
the start of rshift_double does fix the test case on i686 with gcc-4.6.

However, I'm worried that parts of gcc now depend on the extended semantics of
rshift_double and double_int_rshift, so reverting that may be problematic. 
Instead we can robustify rshift_double a bit: if COUNT  0, check if COUNT
equals INTTYPE_MINIMUM (HOST_WIDE_INT), and if so don't negate COUNT and call
lshift_double but instead set COUNT to 2 * HOST_BITS_PER_WIDE_INT.  The
following code will then handle this like other too-large shifts.  This fixes
the test case too with no testsuite regressions on i686 with gcc-4.6.

gcc-4.7 doesn't have the issue on i686 because i686 is now HWI64 (right?), but
other HWI32 platforms like m68k and arm-oabi still have the problem.  I'm
currently testing the 2nd patch with gcc-4.7 on i686 and x86_64.


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2011-10-29 Thread mikpe at it dot uu.se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

Mikael Pettersson mikpe at it dot uu.se changed:

   What|Removed |Added

 CC||mikpe at it dot uu.se

--- Comment #3 from Mikael Pettersson mikpe at it dot uu.se 2011-10-29 
13:29:20 UTC ---
The reduced test case throws 4.6.1 and 4.6-20111021 in a loop on i686-linux,
but 4.4/4.5/4.7 don't loop.  On m68k-linux both 4.6-20111021 and 4.7-20111022
loop.  I haven't been able to reproduce the loop on armv5tel-linux-gnueabi with
any of 4.4/4.5/4.6/4.7.


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2011-10-29 Thread rmansfield at qnx dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

--- Comment #4 from Ryan Mansfield rmansfield at qnx dot com 2011-10-29 
14:28:57 UTC ---
(In reply to comment #3)
 I haven't been able to reproduce the loop on armv5tel-linux-gnueabi with
 any of 4.4/4.5/4.6/4.7.

arm eabi targets force 64bit HOST_WIDE_INT which is why the reduced testcase
didn't fail.


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2011-10-28 Thread rmansfield at qnx dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

--- Comment #2 from Ryan Mansfield rmansfield at qnx dot com 2011-10-29 
01:16:37 UTC ---
My large testcase reduced to:

void
foo ()
{
  unsigned int a = 1  0x8000;
}


[Bug middle-end/50708] Infinite loop between rshift_double and lshift_double if count is LONG_MIN

2011-10-13 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50708

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2011-10-13
 Ever Confirmed|0   |1

--- Comment #1 from Richard Guenther rguenth at gcc dot gnu.org 2011-10-13 
09:26:28 UTC ---
Confirmed.  Not very likely, but ...