Re: Minor VRP jump threading improvement

2011-03-16 Thread Paolo Bonzini

On 03/15/2011 10:37 PM, Jeff Law wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



I noticed that VRP was missing many obvious jump threading
opportunities; investigation showed that it wasn't threading through
conditionals with pointer types, just those with integral types.

Fix is rather obvious.

Bootstrapped and regression tested on x86_64-unknown-linux-gnu.  OK for
trunk?


Do you have a testcase to include?

Paolo


Re: Minor VRP jump threading improvement

2011-03-16 Thread Richard Guenther
On Tue, Mar 15, 2011 at 10:37 PM, Jeff Law l...@redhat.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1



 I noticed that VRP was missing many obvious jump threading
 opportunities; investigation showed that it wasn't threading through
 conditionals with pointer types, just those with integral types.

 Fix is rather obvious.

 Bootstrapped and regression tested on x86_64-unknown-linux-gnu.  OK for
 trunk?

Looks ok (a testcase would be nice).  Btw, you only need to check
the gimple_cond_lhs, the rhs will have a matching type kind.

Thanks,
Richard.




 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.11 (GNU/Linux)
 Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

 iQEcBAEBAgAGBQJNf9wXAAoJEBRtltQi2kC7i3gH+wS6SZNEVwMeHrx04LkRUV7i
 hdWsBKWoWxFCm/JjIVEXkticztRGG2cF6OgtTutXCyYHriVXpHvJSATw0OrYLT2y
 zMjj1+wy9NKcznIaulyYzCadoFiJUuTnZ3pMDGo+gqx7ThqrG11sJ581CnMtZWxA
 Y3tpUBebhovORi4IZOvp2atjIFEnI/CCttxzVyTXtzaflysDr6rbZP75z/AGANI4
 5gkcDkLCEglGHYL6phT0fxHjZAUaIJN/JHTvZ4MGA6lJjO8wG/Z4ZnDmtUURhLiR
 z9th3gBzFtdjlkwcu8U1qulXDaxbMEmLLP3zMgmFthvI+PmqITsoshu3c7nn154=
 =yWE3
 -END PGP SIGNATURE-



Re: Minor VRP jump threading improvement

2011-03-16 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 03/16/11 04:31, Richard Guenther wrote:
 On Tue, Mar 15, 2011 at 10:37 PM, Jeff Law l...@redhat.com wrote:
 
 
 I noticed that VRP was missing many obvious jump threading
 opportunities; investigation showed that it wasn't threading through
 conditionals with pointer types, just those with integral types.
 
 Fix is rather obvious.
 
 Bootstrapped and regression tested on x86_64-unknown-linux-gnu.  OK for
 trunk?
 
 Looks ok (a testcase would be nice). 
Reasonably easy to add a testcase; I don't have the original handy
(already blown away), but it triggers enough that I can construct one
quickly.

 Btw, you only need to check
 the gimple_cond_lhs, the rhs will have a matching type kind.
Yea.  I'll twiddle that and the comment as well.

jeff
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNgL61AAoJEBRtltQi2kC7AnIH/0HRaYKhi0ML64xbyTuzJWXu
llRtjb2lHm5aDLpfP07gJuULnn/eeGyeL8R/LHXcaljWJIPPWQVaI482380K1Xcd
ZcZOpR/FNKEcXM237akXMUk6lt1OSPFHsWhNqe82CqaNdFRsGR6u7kukhZK7XXTk
fnoMYhva75GGuR6W8SRf8uoC/kv91I6elFreUO1hh2RgfJB9cHm8zqzlJ3l+/IRk
KevnGseDKVbvUCDIK9r+h8QxFwLKRLHejdj0tY8WsszqP9tTfvmN21CbD9aovmrA
BMrF1rId1+4ZyR76FlwfJwVKUDWOFPqujdddzmdptH5oY8HGo+PiBoP/tp57oNo=
=j/sQ
-END PGP SIGNATURE-


Re: Minor VRP jump threading improvement

2011-03-16 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 03/16/11 04:31, Richard Guenther wrote:
 On Tue, Mar 15, 2011 at 10:37 PM, Jeff Law l...@redhat.com wrote:
 
 
 I noticed that VRP was missing many obvious jump threading
 opportunities; investigation showed that it wasn't threading through
 conditionals with pointer types, just those with integral types.
 
 Fix is rather obvious.
 
 Bootstrapped and regression tested on x86_64-unknown-linux-gnu.  OK for
 trunk?
 
 Looks ok (a testcase would be nice).  Btw, you only need to check
 the gimple_cond_lhs, the rhs will have a matching type kind.
Testcase added, simplified condition, updated comments.  Bootstrapped
and regression tested on x86_64-unknown-linux-gnu.  Installed on trunk.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNgPSRAAoJEBRtltQi2kC75MIH/3SxIa6+sFS7F1fTH9OXE31f
ohdxBKhIKkjRrJTt3aB0mJjmWMf4ajaXlwhESz1aBecUTE29G5xOnC1G2pychzXH
FCPH+cTf2KqDH7sCJf05tCBkKt15FHX/dHYmy8KPSQi01in2g/wa6QYbDJMJGZUl
pbUUOnjTzWxZOr6+ufF/boaKYU5dw65Yc+ABsgiJ/06vUZAJeBisei2xsdhtwuK1
A1lvW3MUyxx5A+h+dX35w4cS1smJYGSXSvtomcqVTjUVU1yKjGhw/tIfbq8sTkVx
UgUvtEbwl+XoDmIoujzuUxayX1SwEMtMULnE4k0HgVMEvN9+jYzoB7Fe2WeUSV0=
=cf+z
-END PGP SIGNATURE-
Index: ChangeLog
===
*** ChangeLog   (revision 171047)
--- ChangeLog   (working copy)
***
*** 1,3 
--- 1,9 
+ 2011-03-16  Jeff Law  l...@redhat.com
+ 
+   * tree-vrp.c (identify_jump_threads): Slightly simplify type
+   check for operands of conditional.  Allow type to be a
+   pointer.
+ 
  2011-03-16  Richard Guenther  rguent...@suse.de
  
PR tree-optimization/26134
Index: tree-vrp.c
===
*** tree-vrp.c  (revision 171007)
--- tree-vrp.c  (working copy)
*** identify_jump_threads (void)
*** 7538,7549 
continue;
  
/* We're basically looking for any kind of conditional with
!integral type arguments.  */
if (TREE_CODE (gimple_cond_lhs (last)) == SSA_NAME
!  INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (last)))
   (TREE_CODE (gimple_cond_rhs (last)) == SSA_NAME
! || is_gimple_min_invariant (gimple_cond_rhs (last)))
!  INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_rhs (last
{
  edge_iterator ei;
  
--- 7538,7551 
continue;
  
/* We're basically looking for any kind of conditional with
!integral or pointer type arguments.  Note the type of the second
!argument will be the same as the first argument, so no need to
!check it explicitly.  */
if (TREE_CODE (gimple_cond_lhs (last)) == SSA_NAME
!  (INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (last)))
! || POINTER_TYPE_P (TREE_TYPE (gimple_cond_lhs (last
   (TREE_CODE (gimple_cond_rhs (last)) == SSA_NAME
! || is_gimple_min_invariant (gimple_cond_rhs (last
{
  edge_iterator ei;
  
Index: testsuite/gcc.dg/tree-ssa/vrp55.c
===
*** testsuite/gcc.dg/tree-ssa/vrp55.c   (revision 0)
--- testsuite/gcc.dg/tree-ssa/vrp55.c   (revision 0)
***
*** 0 
--- 1,14 
+ /* { dg-do compile } */
+ /* { dg-options -O2 -fdump-tree-vrp1-blocks-vops-details } */
+ 
+ fu (char *p, int x)
+ {
+   if (x)
+*p = 69;
+   if (p)
+ arf ();
+ }
+ 
+ /* { dg-final { scan-tree-dump-times Threaded jump 1 vrp1 } } */
+ /* { dg-final { cleanup-tree-dump vrp1 } } */
+ 
Index: testsuite/ChangeLog
===
*** testsuite/ChangeLog (revision 171047)
--- testsuite/ChangeLog (working copy)
***
*** 1,3 
--- 1,7 
+ 2011-03-16  Jeff Law l...@redhat.com
+ 
+   * gcc.dg/tree-ssa/vrp55.c: New test.
+ 
  2011-03-16  Richard Guenther  rguent...@suse.de
  
PR testsuite/48147