diff mbox

[Boolean,Vector,1/5] Introduce boolean vector to be used as a vector comparison type

Message ID 20151023111240.GC23452@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich Oct. 23, 2015, 11:12 a.m. UTC
On 23 Oct 11:40, Richard Biener wrote:
> On Thu, Oct 22, 2015 at 6:21 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> > On 22 Oct 12:37, Andreas Schwab wrote:
> >> Ilya Enkovich <enkovich.gnu@gmail.com> writes:
> >>
> >> > 2015-10-22 13:13 GMT+03:00 Andreas Schwab <schwab@suse.de>:
> >> >> FAIL: gcc.c-torture/compile/pr54713-1.c   -O0  (internal compiler error)
> >> >
> >> > Can't reproduce it on i386. What's config used?
> >>
> >> http://gcc.gnu.org/ml/gcc-testresults/2015-10/msg02350.html
> >> http://gcc.gnu.org/ml/gcc-testresults/2015-10/msg02361.html
> >> http://gcc.gnu.org/ml/gcc-testresults/2015-10/msg02396.html
> >>
> >> Andreas.
> >>
> >> --
> >> Andreas Schwab, SUSE Labs, schwab@suse.de
> >> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> >> "And now for something completely different."
> >
> > Thanks!
> > The problem is in wrong mboolean vector size in case target cannot provide a mode for it.  I tested it on i386 with vector extension switched off, but with extensions off vector modes still exist, thus I missed this case.  Here is a patch to fix it.  Bootstrapped and regtested on powerpc64le-unknown-linux-gnu.  I see disappeared fails:
> >
> > gcc.c-torture/compile/pr54713-2.c   -O0  (test for excess errors)
> > gcc.c-torture/compile/pr54713-3.c   -O0  (test for excess errors)
> >
> > I believe other targets should be fixed as well.
> >
> > Thanks,
> > Ilya
> > --
> > gcc/
> >
> > 2015-10-22  Ilya Enkovich  <enkovich.gnu@gmail.com>
> >
> >         * tree.c (build_truth_vector_type): Support BLK mode
> >         returned for boolean vector.
> >
> >
> > diff --git a/gcc/tree.c b/gcc/tree.c
> > index 7d10dd6..836b69a 100644
> > --- a/gcc/tree.c
> > +++ b/gcc/tree.c
> > @@ -10654,8 +10654,12 @@ build_truth_vector_type (unsigned nunits, unsigned vector_size)
> >
> >    gcc_assert (mask_mode != VOIDmode);
> >
> > -  unsigned HOST_WIDE_INT esize = GET_MODE_BITSIZE (mask_mode) / nunits;
> > -  gcc_assert (esize * nunits == GET_MODE_BITSIZE (mask_mode));
> > +  unsigned HOST_WIDE_INT vsize = GET_MODE_BITSIZE (mask_mode);
> > +  if (!vsize)
> 
> This should better check for mask_mode == BLKmode instead?

Here is a version with BLKmode check.  I bootstrapped it on powerpc64le-unknown-linux-gnu (c,c++,fotran only) and checked pr54713-2.c, pr54713-3.c are fixed by this patch.  Is it OK for trunk?

Thanks,
Ilya
--
gcc/

2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>

	PR middle-end/68066
	* tree.c (build_truth_vector_type): Support BLK mode
	returned for boolean vector.

Comments

Richard Biener Oct. 23, 2015, 12:51 p.m. UTC | #1
On Fri, Oct 23, 2015 at 1:12 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> On 23 Oct 11:40, Richard Biener wrote:
>> On Thu, Oct 22, 2015 at 6:21 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> > On 22 Oct 12:37, Andreas Schwab wrote:
>> >> Ilya Enkovich <enkovich.gnu@gmail.com> writes:
>> >>
>> >> > 2015-10-22 13:13 GMT+03:00 Andreas Schwab <schwab@suse.de>:
>> >> >> FAIL: gcc.c-torture/compile/pr54713-1.c   -O0  (internal compiler error)
>> >> >
>> >> > Can't reproduce it on i386. What's config used?
>> >>
>> >> http://gcc.gnu.org/ml/gcc-testresults/2015-10/msg02350.html
>> >> http://gcc.gnu.org/ml/gcc-testresults/2015-10/msg02361.html
>> >> http://gcc.gnu.org/ml/gcc-testresults/2015-10/msg02396.html
>> >>
>> >> Andreas.
>> >>
>> >> --
>> >> Andreas Schwab, SUSE Labs, schwab@suse.de
>> >> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
>> >> "And now for something completely different."
>> >
>> > Thanks!
>> > The problem is in wrong mboolean vector size in case target cannot provide a mode for it.  I tested it on i386 with vector extension switched off, but with extensions off vector modes still exist, thus I missed this case.  Here is a patch to fix it.  Bootstrapped and regtested on powerpc64le-unknown-linux-gnu.  I see disappeared fails:
>> >
>> > gcc.c-torture/compile/pr54713-2.c   -O0  (test for excess errors)
>> > gcc.c-torture/compile/pr54713-3.c   -O0  (test for excess errors)
>> >
>> > I believe other targets should be fixed as well.
>> >
>> > Thanks,
>> > Ilya
>> > --
>> > gcc/
>> >
>> > 2015-10-22  Ilya Enkovich  <enkovich.gnu@gmail.com>
>> >
>> >         * tree.c (build_truth_vector_type): Support BLK mode
>> >         returned for boolean vector.
>> >
>> >
>> > diff --git a/gcc/tree.c b/gcc/tree.c
>> > index 7d10dd6..836b69a 100644
>> > --- a/gcc/tree.c
>> > +++ b/gcc/tree.c
>> > @@ -10654,8 +10654,12 @@ build_truth_vector_type (unsigned nunits, unsigned vector_size)
>> >
>> >    gcc_assert (mask_mode != VOIDmode);
>> >
>> > -  unsigned HOST_WIDE_INT esize = GET_MODE_BITSIZE (mask_mode) / nunits;
>> > -  gcc_assert (esize * nunits == GET_MODE_BITSIZE (mask_mode));
>> > +  unsigned HOST_WIDE_INT vsize = GET_MODE_BITSIZE (mask_mode);
>> > +  if (!vsize)
>>
>> This should better check for mask_mode == BLKmode instead?
>
> Here is a version with BLKmode check.  I bootstrapped it on powerpc64le-unknown-linux-gnu (c,c++,fotran only) and checked pr54713-2.c, pr54713-3.c are fixed by this patch.  Is it OK for trunk?

Ok.

Richard.

> Thanks,
> Ilya
> --
> gcc/
>
> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         PR middle-end/68066
>         * tree.c (build_truth_vector_type): Support BLK mode
>         returned for boolean vector.
>
>
> diff --git a/gcc/tree.c b/gcc/tree.c
> index 09df67e..79bbd07 100644
> --- a/gcc/tree.c
> +++ b/gcc/tree.c
> @@ -10671,8 +10671,14 @@ build_truth_vector_type (unsigned nunits, unsigned vector_size)
>
>    gcc_assert (mask_mode != VOIDmode);
>
> -  unsigned HOST_WIDE_INT esize = GET_MODE_BITSIZE (mask_mode) / nunits;
> -  gcc_assert (esize * nunits == GET_MODE_BITSIZE (mask_mode));
> +  unsigned HOST_WIDE_INT vsize;
> +  if (mask_mode == BLKmode)
> +    vsize = vector_size * BITS_PER_UNIT;
> +  else
> +    vsize = GET_MODE_BITSIZE (mask_mode);
> +
> +  unsigned HOST_WIDE_INT esize = vsize / nunits;
> +  gcc_assert (esize * nunits == vsize);
>
>    tree bool_type = build_nonstandard_boolean_type (esize);
>
Christophe Lyon Oct. 28, 2015, 1:44 p.m. UTC | #2
Hi,

Since r229128, I see:
FAIL: c-c++-common/torture/vector-compare-1.c   -O0  execution test
on arm targets, such as arm-none-eabi.

Christophe.
Bill Schmidt Oct. 28, 2015, 4:48 p.m. UTC | #3
On Wed, 2015-10-28 at 14:44 +0100, Christophe Lyon wrote:
> Hi,
> 
> Since r229128, I see:
> FAIL: c-c++-common/torture/vector-compare-1.c   -O0  execution test
> on arm targets, such as arm-none-eabi.

Likewise for powerpc64le-linux-gnu.  The test produces:

0 != ((1.000000 > 0.000000 ? -1 : 0) FAIL: c-c++-common/torture/vector-compare-1
.c   -O0  execution test

> 
> Christophe.
>
Ilya Enkovich Oct. 28, 2015, 7:37 p.m. UTC | #4
Seems the problem occurs in this check in expand_vector_operations_1:

  /* A scalar operation pretending to be a vector one.  */
  if (VECTOR_BOOLEAN_TYPE_P (type)
      && !VECTOR_MODE_P (TYPE_MODE (type))
      && TYPE_MODE (type) != BLKmode)
    return;

This is to filter out scalar operations on boolean vectors.
The problem here is that TYPE_MODE (type) doesn't return
V4SImode assigned to the type but calls vector_type_mode
instead which tries to find an integer mode for it and returns
TImode. This causes function exit and we don't expand vector
comparison.

Suppose simple option to fix it is to change default get_mask_mode
hook to return BLKmode in case chosen integer vector mode is not
vector_mode_supported_p.

Thanks,
Ilya

2015-10-28 19:48 GMT+03:00 Bill Schmidt <wschmidt@linux.vnet.ibm.com>:
> On Wed, 2015-10-28 at 14:44 +0100, Christophe Lyon wrote:
>> Hi,
>>
>> Since r229128, I see:
>> FAIL: c-c++-common/torture/vector-compare-1.c   -O0  execution test
>> on arm targets, such as arm-none-eabi.
>
> Likewise for powerpc64le-linux-gnu.  The test produces:
>
> 0 != ((1.000000 > 0.000000 ? -1 : 0) FAIL: c-c++-common/torture/vector-compare-1
> .c   -O0  execution test
>
>>
>> Christophe.
>>
>
>
diff mbox

Patch

diff --git a/gcc/tree.c b/gcc/tree.c
index 09df67e..79bbd07 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10671,8 +10671,14 @@  build_truth_vector_type (unsigned nunits, unsigned vector_size)
 
   gcc_assert (mask_mode != VOIDmode);
 
-  unsigned HOST_WIDE_INT esize = GET_MODE_BITSIZE (mask_mode) / nunits;
-  gcc_assert (esize * nunits == GET_MODE_BITSIZE (mask_mode));
+  unsigned HOST_WIDE_INT vsize;
+  if (mask_mode == BLKmode)
+    vsize = vector_size * BITS_PER_UNIT;
+  else
+    vsize = GET_MODE_BITSIZE (mask_mode);
+
+  unsigned HOST_WIDE_INT esize = vsize / nunits;
+  gcc_assert (esize * nunits == vsize);
 
   tree bool_type = build_nonstandard_boolean_type (esize);