public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/47061] New: VRP doesn't propagate through x<<=1, but it does for x*=2
@ 2010-12-24 15:28 zsojka at seznam dot cz
  2010-12-24 15:54 ` [Bug tree-optimization/47061] " zsojka at seznam dot cz
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zsojka at seznam dot cz @ 2010-12-24 15:28 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: VRP doesn't propagate through x<<=1, but it does for
                    x*=2
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zsojka@seznam.cz


Created attachment 22850
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22850
testcase

The attached testcase should be optimised to "return 0;", as it is when
x <<= 1;
is replaced by
x *= 2;

$ gcc -O3 pr47061.c -fdump-tree-vrp -S -masm=intel
shows in the .vrp1/2 dumps (among others):

x_1: [-10, -9]
x_2: [-10, -8]
x_3: [-10, -7]
x_4: [-10, -6]
x_11: [-9, -8]
x_14: [-9, -7]
x_17: [-9, -6]
x_18: VARYING

...

<bb 10>:
  # x_4 = PHI <x_3(8), x_17(9)>
  x_18 = x_4 << 2;

Neither gcc version I tested works (3.3.6-4.6.0)


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

* [Bug tree-optimization/47061] VRP doesn't propagate through x<<=1, but it does for x*=2
  2010-12-24 15:28 [Bug tree-optimization/47061] New: VRP doesn't propagate through x<<=1, but it does for x*=2 zsojka at seznam dot cz
@ 2010-12-24 15:54 ` zsojka at seznam dot cz
  2010-12-24 19:25 ` zsojka at seznam dot cz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: zsojka at seznam dot cz @ 2010-12-24 15:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Zdenek Sojka <zsojka at seznam dot cz> 2010-12-24 15:54:35 UTC ---
Created attachment 22851
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22851
another testcase

This testcase seems to be optimised at the RTL level.

$ gcc pr47061-2.c -S -O3 -fdump-tree-vrp

.vrp1/2 dumps show:
...
c_1(D): VARYING
D.2684_2: [-128, 127]
i_3: VARYING
D.2685_4: [0, 1]
...
<bb 2>:
  D.2684_2 = (int) c_1(D);
  i_3 = D.2684_2 << 1;
  D.2685_4 = i_3 > 1000;
  return D.2685_4;
...

So the value is known before the shift as well. For the right shift, the
function is optimised correctly.


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

* [Bug tree-optimization/47061] VRP doesn't propagate through x<<=1, but it does for x*=2
  2010-12-24 15:28 [Bug tree-optimization/47061] New: VRP doesn't propagate through x<<=1, but it does for x*=2 zsojka at seznam dot cz
  2010-12-24 15:54 ` [Bug tree-optimization/47061] " zsojka at seznam dot cz
@ 2010-12-24 19:25 ` zsojka at seznam dot cz
  2010-12-28 15:04 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: zsojka at seznam dot cz @ 2010-12-24 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zdenek Sojka <zsojka at seznam dot cz> 2010-12-24 19:25:21 UTC ---
(In reply to comment #1)
> For the right shift, the
> function is optimised correctly.

Actually, no, it's just the cast what optimises the range, but not the shift -
.vrp1 dump for "int i = c >> 1;":
...
c_1(D): VARYING
D.2684_2: VARYING
i_3: [-128, 127]
D.2685_4: [0, 0]
...
<bb 2>:
  D.2684_2 = c_1(D) >> 1;
  i_3 = (int) D.2684_2;
  D.2685_4 = 0;
  return 0;
...


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

* [Bug tree-optimization/47061] VRP doesn't propagate through x<<=1, but it does for x*=2
  2010-12-24 15:28 [Bug tree-optimization/47061] New: VRP doesn't propagate through x<<=1, but it does for x*=2 zsojka at seznam dot cz
  2010-12-24 15:54 ` [Bug tree-optimization/47061] " zsojka at seznam dot cz
  2010-12-24 19:25 ` zsojka at seznam dot cz
@ 2010-12-28 15:04 ` rguenth at gcc dot gnu.org
  2012-06-29 14:25 ` rguenth at gcc dot gnu.org
  2012-06-29 14:27 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-12-28 15:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2010.12.28 15:04:25
                 CC|                            |rguenth at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-12-28 15:04:25 UTC ---
VRP needs a lot of TLC with respect to how it treats ranges with constant
bounds.
Yes, it doesn't handle shifts at all at the moment.


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

* [Bug tree-optimization/47061] VRP doesn't propagate through x<<=1, but it does for x*=2
  2010-12-24 15:28 [Bug tree-optimization/47061] New: VRP doesn't propagate through x<<=1, but it does for x*=2 zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2010-12-28 15:04 ` rguenth at gcc dot gnu.org
@ 2012-06-29 14:25 ` rguenth at gcc dot gnu.org
  2012-06-29 14:27 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-06-29 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-29 14:25:38 UTC ---
Fixed by my simple LSHIFT_EXPR handling code.  I'll add the testcases.


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

* [Bug tree-optimization/47061] VRP doesn't propagate through x<<=1, but it does for x*=2
  2010-12-24 15:28 [Bug tree-optimization/47061] New: VRP doesn't propagate through x<<=1, but it does for x*=2 zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2012-06-29 14:25 ` rguenth at gcc dot gnu.org
@ 2012-06-29 14:27 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-06-29 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-29 14:27:34 UTC ---
Author: rguenth
Date: Fri Jun 29 14:27:24 2012
New Revision: 189076

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189076
Log:
2012-06-29  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/47061
    * gcc.dg/tree-ssa/vrp71.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp71.c
Modified:
    trunk/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2012-06-29 14:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-24 15:28 [Bug tree-optimization/47061] New: VRP doesn't propagate through x<<=1, but it does for x*=2 zsojka at seznam dot cz
2010-12-24 15:54 ` [Bug tree-optimization/47061] " zsojka at seznam dot cz
2010-12-24 19:25 ` zsojka at seznam dot cz
2010-12-28 15:04 ` rguenth at gcc dot gnu.org
2012-06-29 14:25 ` rguenth at gcc dot gnu.org
2012-06-29 14:27 ` rguenth 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).