middle-end: move bitmask match.pd pattern and update tests

Message ID patch-15110-tamar@arm.com
State New
Headers
Series middle-end: move bitmask match.pd pattern and update tests |

Commit Message

Tamar Christina Nov. 29, 2021, 12:27 p.m. UTC
  Hi All,

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.

Bootstrapped Regtested x86_64-pc-linux-gnu and no regressions.
Tested with -m32/-mno-sse and no issues.

Ok for master?

Thanks,
Tamar

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.

--- inline copy of patch -- 
diff --git a/gcc/match.pd b/gcc/match.pd
index e14f97ee1cda805f4e416a236de0d1770e9c933d..10a47e941529fdb25898f421b780a035dd8f8eff 100644


--
  

Comments

Richard Biener Nov. 29, 2021, 12:42 p.m. UTC | #1
On Mon, 29 Nov 2021, Tamar Christina wrote:

> Hi All,
> 
> 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.
> 
> Bootstrapped Regtested x86_64-pc-linux-gnu and no regressions.
> Tested with -m32/-mno-sse and no issues.
> 
> Ok for master?

OK.

Richard.

> Thanks,
> Tamar
> 
> 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.
> 
> --- inline copy of patch -- 
> diff --git a/gcc/match.pd b/gcc/match.pd
> index e14f97ee1cda805f4e416a236de0d1770e9c933d..10a47e941529fdb25898f421b780a035dd8f8eff 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -5213,20 +5213,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)
> @@ -5713,6 +5699,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 0d0416028ebe5d5d16c03cfec357b3aad31703c7..fe4f677b64dc96862683faf503eb4900a01e7407 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 0e589c96290286f02cddc27f33f25f0f7b3bb028..b77f4d42450fe6496d277a4429f0e051f5178781 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 50eb563f3b1a556019a33b4c23c588215268976d..30d36f452014cdb90eeccf6eb7f0a4cd6d8f8234 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-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 59ba9a414ae6455e5b4934861c66150207718b89..58c0b9254badc2aeae01bd181a60830ed3eba44a 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-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 b41651b962f12f0926783ce336b427fd6d07831e..67119d32f751fa107b5d4927809e122c1bcbf3ef 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-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 59ba9a414ae6455e5b4934861c66150207718b89..58c0b9254badc2aeae01bd181a60830ed3eba44a 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-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 7e0614d458ca80e3abb847108a419e1d183495a2..6e2da41bac127d82a6a83f3e99c6f68b77ac2b42 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 e71b17d12727e943726a163240da4914beb181f1..5ef0f46c0b1709db633d3aa801cd7211baef31ef 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 a48a226efc15ca6d56146e8fe7f4e6ff8bfaa632..22e5f885bebea9a141e9ffdd0ea7276a5a9046aa 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 cd06e0ce7be1bca568c76532575fded1e13e979e..edff5428c5455f3b6597f561b53948ad21be05ad 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 3d88b74787ad4320d34e424fc08f952f9ff00c98..319d80e672f231e4a96d4d22bc68f6b9ea464a74 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 910fb06d6f551947fae235b99a4cd88bd84e3c85..94350f9c73d9b7f9d38c44e297356882faa9f5de 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 ();
>  }
> 
> 
>
  

Patch

diff --git a/gcc/match.pd b/gcc/match.pd
index e14f97ee1cda805f4e416a236de0d1770e9c933d..10a47e941529fdb25898f421b780a035dd8f8eff 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -5213,20 +5213,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)
@@ -5713,6 +5699,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 0d0416028ebe5d5d16c03cfec357b3aad31703c7..fe4f677b64dc96862683faf503eb4900a01e7407 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 0e589c96290286f02cddc27f33f25f0f7b3bb028..b77f4d42450fe6496d277a4429f0e051f5178781 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 50eb563f3b1a556019a33b4c23c588215268976d..30d36f452014cdb90eeccf6eb7f0a4cd6d8f8234 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-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 59ba9a414ae6455e5b4934861c66150207718b89..58c0b9254badc2aeae01bd181a60830ed3eba44a 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-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 b41651b962f12f0926783ce336b427fd6d07831e..67119d32f751fa107b5d4927809e122c1bcbf3ef 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-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 59ba9a414ae6455e5b4934861c66150207718b89..58c0b9254badc2aeae01bd181a60830ed3eba44a 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-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 7e0614d458ca80e3abb847108a419e1d183495a2..6e2da41bac127d82a6a83f3e99c6f68b77ac2b42 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 e71b17d12727e943726a163240da4914beb181f1..5ef0f46c0b1709db633d3aa801cd7211baef31ef 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 a48a226efc15ca6d56146e8fe7f4e6ff8bfaa632..22e5f885bebea9a141e9ffdd0ea7276a5a9046aa 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 cd06e0ce7be1bca568c76532575fded1e13e979e..edff5428c5455f3b6597f561b53948ad21be05ad 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 3d88b74787ad4320d34e424fc08f952f9ff00c98..319d80e672f231e4a96d4d22bc68f6b9ea464a74 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 910fb06d6f551947fae235b99a4cd88bd84e3c85..94350f9c73d9b7f9d38c44e297356882faa9f5de 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 ();
 }