public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5650] middle-end: move bitmask match.pd pattern and update tests
@ 2021-12-01  8:41 Tamar Christina
  0 siblings, 0 replies; only message in thread
From: Tamar Christina @ 2021-12-01  8:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:29df53fe349073a9210df70ae45662cb3f4a0556

commit r12-5650-g29df53fe349073a9210df70ae45662cb3f4a0556
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Wed Dec 1 08:40:25 2021 +0000

    middle-end: move bitmask match.pd pattern and update tests
    
    Following the previous bugfix this addresses the cosmetic and test issues.
    
    The vector tests are moved to vect and the scalar are left where they are.
    
    gcc/ChangeLog:
    
            * match.pd: Move below pattern that rewrites to EQ, NE.
            * tree.c (bitmask_inv_cst_vector_p): Correct do .. while indentation.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/bic-bitmask-10.c: Moved to gcc.dg/vect/vect-bic-bitmask-10.c.
            * gcc.dg/bic-bitmask-11.c: Moved to gcc.dg/vect/vect-bic-bitmask-11.c.
            * gcc.dg/bic-bitmask-12.c: Moved to gcc.dg/vect/vect-bic-bitmask-12.c.
            * gcc.dg/bic-bitmask-3.c: Moved to gcc.dg/vect/vect-bic-bitmask-3.c.
            * gcc.dg/bic-bitmask-23.c: Moved to gcc.dg/vect/vect-bic-bitmask-23.c.
            * gcc.dg/bic-bitmask-2.c: Moved to gcc.dg/vect/vect-bic-bitmask-2.c.
            * gcc.dg/bic-bitmask-4.c: Moved to gcc.dg/vect/vect-bic-bitmask-4.c.
            * gcc.dg/bic-bitmask-5.c: Moved to gcc.dg/vect/vect-bic-bitmask-5.c.
            * gcc.dg/bic-bitmask-6.c: Moved to gcc.dg/vect/vect-bic-bitmask-6.c.
            * gcc.dg/bic-bitmask-8.c: Moved to gcc.dg/vect/vect-bic-bitmask-8.c.
            * gcc.dg/bic-bitmask-9.c: Moved to gcc.dg/vect/vect-bic-bitmask-9.c.

Diff:
---
 gcc/match.pd                                       | 28 +++++++++++-----------
 .../vect-bic-bitmask-10.c}                         |  4 ++--
 .../vect-bic-bitmask-11.c}                         |  4 ++--
 .../vect-bic-bitmask-12.c}                         |  2 +-
 .../{bic-bitmask-3.c => vect/vect-bic-bitmask-2.c} |  4 ++--
 .../vect-bic-bitmask-23.c}                         |  2 +-
 .../{bic-bitmask-2.c => vect/vect-bic-bitmask-3.c} |  4 ++--
 .../{bic-bitmask-4.c => vect/vect-bic-bitmask-4.c} |  4 ++--
 .../{bic-bitmask-5.c => vect/vect-bic-bitmask-5.c} |  4 ++--
 .../{bic-bitmask-6.c => vect/vect-bic-bitmask-6.c} |  4 ++--
 .../{bic-bitmask-8.c => vect/vect-bic-bitmask-8.c} |  4 ++--
 .../{bic-bitmask-9.c => vect/vect-bic-bitmask-9.c} |  4 ++--
 gcc/tree.c                                         | 28 ++++++++++++----------
 13 files changed, 49 insertions(+), 47 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index d467a1c4e45..0a00b08e2ab 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -5215,20 +5215,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
       (eqcmp (bit_and @1 { wide_int_to_tree (ty, mask - rhs); })
 	     { build_zero_cst (ty); }))))))
 
-/* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
-   where ~Y + 1 == pow2 and Z = ~Y.  */
-(for cst (VECTOR_CST INTEGER_CST)
- (for cmp (eq ne)
-      icmp (le gt)
-  (simplify
-   (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
-    (with { tree csts = bitmask_inv_cst_vector_p (@1); }
-     (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
-      (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
-       (icmp @0 { csts; })
-       (with { tree utype = unsigned_type_for (TREE_TYPE (@1)); }
-	 (icmp (convert:utype @0) { csts; }))))))))
-
 /* -A CMP -B -> B CMP A.  */
 (for cmp (tcc_comparison)
      scmp (swapped_tcc_comparison)
@@ -5715,6 +5701,20 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    replace if (x == 0) with tem = ~x; if (tem != 0) which is
    clearly less optimal and which we'll transform again in forwprop.  */
 
+/* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
+   where ~Y + 1 == pow2 and Z = ~Y.  */
+(for cst (VECTOR_CST INTEGER_CST)
+ (for cmp (eq ne)
+      icmp (le gt)
+  (simplify
+   (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
+    (with { tree csts = bitmask_inv_cst_vector_p (@1); }
+     (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
+      (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
+       (icmp @0 { csts; })
+       (with { tree utype = unsigned_type_for (TREE_TYPE (@1)); }
+	 (icmp (convert:utype @0) { csts; }))))))))
+
 /* When one argument is a constant, overflow detection can be simplified.
    Currently restricted to single use so as not to interfere too much with
    ADD_OVERFLOW detection in tree-ssa-math-opts.c.
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-10.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-10.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-10.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-10.c
index 0d0416028eb..fe4f677b64d 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-10.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-10.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -save-temps -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
@@ -18,7 +18,7 @@ void fun2(int32_t *x, int n)
 }
 
 #define TYPE int32_t
-#include "bic-bitmask.h"
+#include "../bic-bitmask.h"
 
 /* { dg-final { scan-tree-dump {<=\s*.+\{ 255,.+\}} dce7 { target vect_int } } } */
 /* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967290,.+\}} dce7 { target vect_int } } } */
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-11.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-11.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-11.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-11.c
index 0e589c96290..b77f4d42450 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-11.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-11.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -save-temps -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
@@ -17,7 +17,7 @@ void fun2(uint32_t *x, int n)
       x[i] = (x[i]&(~255)) != 0;
 }
 
-#include "bic-bitmask.h"
+#include "../bic-bitmask.h"
 
 /* { dg-final { scan-tree-dump {>\s*.+\{ 255,.+\}} dce7 { target vect_int } } } */
 /* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967290,.+\}} dce7 { target vect_int } } } */
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-12.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-12.c
similarity index 89%
rename from gcc/testsuite/gcc.dg/bic-bitmask-12.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-12.c
index 50eb563f3b1..30d36f45201 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-12.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-12.c
@@ -1,5 +1,5 @@
 /* { dg-do assemble } */
-/* { dg-options "-O3 -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-3.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-2.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-3.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-2.c
index 59ba9a414ae..58c0b9254ba 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-3.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-2.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -save-temps -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
@@ -17,7 +17,7 @@ void fun2(uint32_t *x, int n)
       x[i] = (x[i]&(~255)) == 0;
 }
 
-#include "bic-bitmask.h"
+#include "../bic-bitmask.h"
 
 /* { dg-final { scan-tree-dump-times {<=\s*.+\{ 255,.+\}} 1 dce7 { target vect_int } } } */
 /* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-23.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-23.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-23.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-23.c
index b41651b962f..67119d32f75 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-23.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-23.c
@@ -1,5 +1,5 @@
 /* { dg-do assemble } */
-/* { dg-options "-O1 -fdump-tree-dce" } */
+/* { dg-additional-options "-O1 -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-2.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-3.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-2.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-3.c
index 59ba9a414ae..58c0b9254ba 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-2.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-3.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -save-temps -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
@@ -17,7 +17,7 @@ void fun2(uint32_t *x, int n)
       x[i] = (x[i]&(~255)) == 0;
 }
 
-#include "bic-bitmask.h"
+#include "../bic-bitmask.h"
 
 /* { dg-final { scan-tree-dump-times {<=\s*.+\{ 255,.+\}} 1 dce7 { target vect_int } } } */
 /* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-4.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-4.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-4.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-4.c
index 7e0614d458c..6e2da41bac1 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-4.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-4.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -save-temps -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
@@ -17,7 +17,7 @@ void fun2(uint32_t *x, int n)
       x[i] = (x[i]&(~255)) >= 0;
 }
 
-#include "bic-bitmask.h"
+#include "../bic-bitmask.h"
 
 /* { dg-final { scan-tree-dump-times {=\s*.+\{ 1,.+\}} 1 dce7 { target vect_int } } } */
 /* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-5.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-5.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-5.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-5.c
index e71b17d1272..5ef0f46c0b1 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-5.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-5.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -save-temps -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
@@ -17,7 +17,7 @@ void fun2(uint32_t *x, int n)
       x[i] = (x[i]&(~255)) > 0;
 }
 
-#include "bic-bitmask.h"
+#include "../bic-bitmask.h"
 
 /* { dg-final { scan-tree-dump-times {>\s*.+\{ 255,.+\}} 1 dce7 { target vect_int } } } */
 /* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-6.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-6.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-6.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-6.c
index a48a226efc1..22e5f885beb 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-6.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-6.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -save-temps -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
@@ -17,7 +17,7 @@ void fun2(uint32_t *x, int n)
       x[i] = (x[i]&(~255)) <= 0;
 }
 
-#include "bic-bitmask.h"
+#include "../bic-bitmask.h"
 
 /* { dg-final { scan-tree-dump-times {<=\s*.+\{ 255,.+\}} 1 dce7 { target vect_int } } } */
 /* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-8.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-8.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-8.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-8.c
index cd06e0ce7be..edff5428c54 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-8.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-8.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -save-temps -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
@@ -17,7 +17,7 @@ void fun2(uint32_t *x, int n)
       x[i] = (x[i]&(~1)) != 0;
 }
 
-#include "bic-bitmask.h"
+#include "../bic-bitmask.h"
 
 /* { dg-final { scan-tree-dump-times {>\s*.+\{ 1,.+\}} 1 dce7 { target vect_int } } } */
 /* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967294,.+\}} dce7 { target vect_int } } } */
diff --git a/gcc/testsuite/gcc.dg/bic-bitmask-9.c b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-9.c
similarity index 86%
rename from gcc/testsuite/gcc.dg/bic-bitmask-9.c
rename to gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-9.c
index 3d88b74787a..319d80e672f 100644
--- a/gcc/testsuite/gcc.dg/bic-bitmask-9.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bic-bitmask-9.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */
+/* { dg-additional-options "-O3 -save-temps -fdump-tree-dce -w" } */
 
 #include <stdint.h>
 
@@ -17,7 +17,7 @@ void fun2(uint32_t *x, int n)
       x[i] = (x[i]&(~5)) == 0;
 }
 
-#include "bic-bitmask.h"
+#include "../bic-bitmask.h"
 
 /* { dg-final { scan-tree-dump-not {<=\s*.+\{ 4294967289,.+\}} dce7 { target vect_int } } } */
 /* { dg-final { scan-tree-dump {&\s*.+\{ 4294967290,.+\}} dce7 { target vect_int } } } */
diff --git a/gcc/tree.c b/gcc/tree.c
index 4d91fdea758..72cceda568f 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10306,22 +10306,24 @@ bitmask_inv_cst_vector_p (tree t)
 
   tree ty = unsigned_type_for (TREE_TYPE (cst));
 
-  do {
-    if (idx > 0)
-      cst = vector_cst_elt (t, idx);
-    wide_int icst = wi::to_wide (cst);
-    wide_int inv =  wi::bit_not (icst);
-    icst = wi::add (1, inv);
-    if (wi::popcount (icst) != 1)
-      return NULL_TREE;
+  do
+    {
+      if (idx > 0)
+	cst = vector_cst_elt (t, idx);
+      wide_int icst = wi::to_wide (cst);
+      wide_int inv =  wi::bit_not (icst);
+      icst = wi::add (1, inv);
+      if (wi::popcount (icst) != 1)
+	return NULL_TREE;
 
-    tree newcst = wide_int_to_tree (ty, inv);
+      tree newcst = wide_int_to_tree (ty, inv);
 
-    if (uniform)
-      return build_uniform_cst (newtype, newcst);
+      if (uniform)
+	return build_uniform_cst (newtype, newcst);
 
-    builder.quick_push (newcst);
-  } while (++idx < nelts);
+      builder.quick_push (newcst);
+    }
+  while (++idx < nelts);
 
   return builder.build ();
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-01  8:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01  8:41 [gcc r12-5650] middle-end: move bitmask match.pd pattern and update tests Tamar Christina

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).