diff mbox

Testcase for nonzero_bits & __builtin_unreachable

Message ID 20131029072420.GU30970@tucnak.zalov.cz
State New
Headers show

Commit Message

Jakub Jelinek Oct. 29, 2013, 7:24 a.m. UTC
On Sat, Oct 26, 2013 at 12:19:33AM +0200, Jakub Jelinek wrote:
> And here is a patch that allows vectorization without peeling for alignment
> and scalar loop for bound even for fn2, fn3 and fn4 in the following
> testcase, though as with the range __builtin_unreachable () notes, it is
> quite fragile, because it only works if there are no immediate uses of the
> tested SSA_NAME before the assertion.  Perhaps more reliable way would be to
> convert those assertions info __builtin_assume_aligned, but that has the
> disadvantage that it's first argument is a pointer and it returns a pointer,
> so we'd need to cast integers to pointers and back, or add ASSUME_ALIGNED
> internal function.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux.

And here is as a follow-up to the whole patchset of 4 patches a testcase:

2013-10-29  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/vect/vect-align-3.c: New test.


	Jakub

Comments

Richard Biener Oct. 29, 2013, 2:54 p.m. UTC | #1
On Tue, 29 Oct 2013, Jakub Jelinek wrote:

> On Sat, Oct 26, 2013 at 12:19:33AM +0200, Jakub Jelinek wrote:
> > And here is a patch that allows vectorization without peeling for alignment
> > and scalar loop for bound even for fn2, fn3 and fn4 in the following
> > testcase, though as with the range __builtin_unreachable () notes, it is
> > quite fragile, because it only works if there are no immediate uses of the
> > tested SSA_NAME before the assertion.  Perhaps more reliable way would be to
> > convert those assertions info __builtin_assume_aligned, but that has the
> > disadvantage that it's first argument is a pointer and it returns a pointer,
> > so we'd need to cast integers to pointers and back, or add ASSUME_ALIGNED
> > internal function.
> > 
> > Bootstrapped/regtested on x86_64-linux and i686-linux.
> 
> And here is as a follow-up to the whole patchset of 4 patches a testcase:

Ok.

Thanks,
Richard.

> 2013-10-29  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* gcc.dg/vect/vect-align-3.c: New test.
> 
> --- gcc/testsuite/gcc.dg/vect/vect-align-3.c.jj	2013-10-29 08:18:08.636348586 +0100
> +++ gcc/testsuite/gcc.dg/vect/vect-align-3.c	2013-10-29 08:21:14.931384138 +0100
> @@ -0,0 +1,54 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target vect_int } */
> +
> +int a[2048];
> +
> +void
> +f1 (int x, int y)
> +{
> +  int i;
> +  x &= -256;
> +  y &= -256;
> +  for (i = x + 256; i < y; i++)
> +    a[i]++;
> +}
> +
> +void
> +f2 (int x, int y)
> +{
> +  int i;
> +  if (x & 31)
> +    __builtin_unreachable ();
> +  if (y & 31)
> +    __builtin_unreachable ();
> +  for (i = x + 256; i < x + y; i++)
> +    a[i]++;
> +}
> +
> +void
> +f3 (int x, int y)
> +{
> +  int i;
> +  if (x % 256)
> +    __builtin_unreachable ();
> +  if (y % 256)
> +    __builtin_unreachable ();
> +  for (i = x + 256; i < x + y; i++)
> +    a[i]++;
> +}
> +
> +void
> +f4 (int x, int y)
> +{
> +  int i;
> +  if ((x % 256) != 0)
> +    __builtin_unreachable ();
> +  if ((y % 256) != 0)
> +    __builtin_unreachable ();
> +  for (i = x + 256; i < x + y; i++)
> +    a[i]++;
> +}
> +
> +/* { dg-final { scan-tree-dump-not "vect_do_peeling_for_loop_bound" "vect" } } */
> +/* { dg-final { scan-tree-dump-not "loop peeled for vectorization" "vect" } } */
> +/* { dg-final { cleanup-tree-dump "vect" } } */
> 
> 	Jakub
> 
>
diff mbox

Patch

--- gcc/testsuite/gcc.dg/vect/vect-align-3.c.jj	2013-10-29 08:18:08.636348586 +0100
+++ gcc/testsuite/gcc.dg/vect/vect-align-3.c	2013-10-29 08:21:14.931384138 +0100
@@ -0,0 +1,54 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+int a[2048];
+
+void
+f1 (int x, int y)
+{
+  int i;
+  x &= -256;
+  y &= -256;
+  for (i = x + 256; i < y; i++)
+    a[i]++;
+}
+
+void
+f2 (int x, int y)
+{
+  int i;
+  if (x & 31)
+    __builtin_unreachable ();
+  if (y & 31)
+    __builtin_unreachable ();
+  for (i = x + 256; i < x + y; i++)
+    a[i]++;
+}
+
+void
+f3 (int x, int y)
+{
+  int i;
+  if (x % 256)
+    __builtin_unreachable ();
+  if (y % 256)
+    __builtin_unreachable ();
+  for (i = x + 256; i < x + y; i++)
+    a[i]++;
+}
+
+void
+f4 (int x, int y)
+{
+  int i;
+  if ((x % 256) != 0)
+    __builtin_unreachable ();
+  if ((y % 256) != 0)
+    __builtin_unreachable ();
+  for (i = x + 256; i < x + y; i++)
+    a[i]++;
+}
+
+/* { dg-final { scan-tree-dump-not "vect_do_peeling_for_loop_bound" "vect" } } */
+/* { dg-final { scan-tree-dump-not "loop peeled for vectorization" "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */