public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR68062] Fix uniform vector operation lowering
@ 2015-10-23 15:32 Ilya Enkovich
  2015-10-23 22:23 ` Jeff Law
  0 siblings, 1 reply; 7+ messages in thread
From: Ilya Enkovich @ 2015-10-23 15:32 UTC (permalink / raw)
  To: gcc-patches

Hi,

This patch checks optab exists before using it vector vector statement lowering.  It fixes compilation of test from PR68062 with -funsigned-char option added (doesn't fix original testcase).  Bootstrapped for x86_64-unknown-linux-gnu.  OK for trunk if no regressions?

Thanks,
Ilya
--
gcc/

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

	* tree-vect-generic.c (expand_vector_operations_1): Check
	optab exists before use it.

gcc/testsuite/

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

	* g++.dg/pr68062.C: New test.


diff --git a/gcc/testsuite/g++.dg/pr68062.C b/gcc/testsuite/g++.dg/pr68062.C
new file mode 100644
index 0000000..236a488
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr68062.C
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-funsigned-char" } */
+
+typedef char __attribute__ ((vector_size (4))) v4qi;
+typedef unsigned char __attribute__ ((vector_size (4))) uv4qi;
+
+v4qi v;
+void ret(char a)
+{
+  v4qi c={a,a,a,a};
+  uv4qi d={a,a,a,a};
+  v = (c!=d);
+}
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index 2005383..9c59402 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -1533,7 +1533,8 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
       && TYPE_MODE (TREE_TYPE (type)) == TYPE_MODE (TREE_TYPE (srhs1)))
     {
       op = optab_for_tree_code (code, TREE_TYPE (type), optab_scalar);
-      if (optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
+      if (op != unknown_optab
+	  && optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
 	{
 	  tree slhs = make_ssa_name (TREE_TYPE (srhs1));
 	  gimple *repl = gimple_build_assign (slhs, code, srhs1, srhs2);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, PR68062] Fix uniform vector operation lowering
  2015-10-23 15:32 [PATCH, PR68062] Fix uniform vector operation lowering Ilya Enkovich
@ 2015-10-23 22:23 ` Jeff Law
  2015-10-23 22:34   ` Ilya Enkovich
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Law @ 2015-10-23 22:23 UTC (permalink / raw)
  To: Ilya Enkovich, gcc-patches

On 10/23/2015 09:26 AM, Ilya Enkovich wrote:
> Hi,
>
> This patch checks optab exists before using it vector vector statement lowering.  It fixes compilation of test from PR68062 with -funsigned-char option added (doesn't fix original testcase).  Bootstrapped for x86_64-unknown-linux-gnu.  OK for trunk if no regressions?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
> 	* tree-vect-generic.c (expand_vector_operations_1): Check
> 	optab exists before use it.
>
> gcc/testsuite/
>
> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
> 	* g++.dg/pr68062.C: New test.
OK.

Just curious, what was the tree code for which we couldn't find a 
suitable optab?

jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, PR68062] Fix uniform vector operation lowering
  2015-10-23 22:23 ` Jeff Law
@ 2015-10-23 22:34   ` Ilya Enkovich
  2015-10-26  9:11     ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: Ilya Enkovich @ 2015-10-23 22:34 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

2015-10-24 0:32 GMT+03:00 Jeff Law <law@redhat.com>:
> On 10/23/2015 09:26 AM, Ilya Enkovich wrote:
>>
>> Hi,
>>
>> This patch checks optab exists before using it vector vector statement
>> lowering.  It fixes compilation of test from PR68062 with -funsigned-char
>> option added (doesn't fix original testcase).  Bootstrapped for
>> x86_64-unknown-linux-gnu.  OK for trunk if no regressions?
>>
>> Thanks,
>> Ilya
>> --
>> gcc/
>>
>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
>>
>>         * tree-vect-generic.c (expand_vector_operations_1): Check
>>         optab exists before use it.
>>
>> gcc/testsuite/
>>
>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
>>
>>         * g++.dg/pr68062.C: New test.
>
> OK.
>
> Just curious, what was the tree code for which we couldn't find a suitable
> optab?

Those are various comparison codes.

Ilya

>
> jeff
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, PR68062] Fix uniform vector operation lowering
  2015-10-23 22:34   ` Ilya Enkovich
@ 2015-10-26  9:11     ` Richard Biener
  2015-10-26  9:36       ` Ilya Enkovich
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Biener @ 2015-10-26  9:11 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Jeff Law, gcc-patches

On Sat, Oct 24, 2015 at 12:29 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2015-10-24 0:32 GMT+03:00 Jeff Law <law@redhat.com>:
>> On 10/23/2015 09:26 AM, Ilya Enkovich wrote:
>>>
>>> Hi,
>>>
>>> This patch checks optab exists before using it vector vector statement
>>> lowering.  It fixes compilation of test from PR68062 with -funsigned-char
>>> option added (doesn't fix original testcase).  Bootstrapped for
>>> x86_64-unknown-linux-gnu.  OK for trunk if no regressions?
>>>
>>> Thanks,
>>> Ilya
>>> --
>>> gcc/
>>>
>>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
>>>
>>>         * tree-vect-generic.c (expand_vector_operations_1): Check
>>>         optab exists before use it.
>>>
>>> gcc/testsuite/
>>>
>>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
>>>
>>>         * g++.dg/pr68062.C: New test.
>>
>> OK.
>>
>> Just curious, what was the tree code for which we couldn't find a suitable
>> optab?
>
> Those are various comparison codes.

Yeah, sorry for missing that check.  Btw, I was curious to see that we miss
a way to query from optab_tag the "kind" (normal, conversion, etc.) so code
can decide what optab_handler function to call (optab_handler or
convert_optab_handler).  So the code I added errs on the "simplistic" side
and hopes that matching lhs and rhs1 type always gets us a non-convert optab...

Richard.

> Ilya
>
>>
>> jeff
>>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, PR68062] Fix uniform vector operation lowering
  2015-10-26  9:11     ` Richard Biener
@ 2015-10-26  9:36       ` Ilya Enkovich
  2015-10-26  9:56         ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: Ilya Enkovich @ 2015-10-26  9:36 UTC (permalink / raw)
  To: Richard Biener; +Cc: Jeff Law, gcc-patches

On 26 Oct 10:09, Richard Biener wrote:
> On Sat, Oct 24, 2015 at 12:29 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> > 2015-10-24 0:32 GMT+03:00 Jeff Law <law@redhat.com>:
> >> On 10/23/2015 09:26 AM, Ilya Enkovich wrote:
> >>>
> >>> Hi,
> >>>
> >>> This patch checks optab exists before using it vector vector statement
> >>> lowering.  It fixes compilation of test from PR68062 with -funsigned-char
> >>> option added (doesn't fix original testcase).  Bootstrapped for
> >>> x86_64-unknown-linux-gnu.  OK for trunk if no regressions?
> >>>
> >>> Thanks,
> >>> Ilya
> >>> --
> >>> gcc/
> >>>
> >>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
> >>>
> >>>         * tree-vect-generic.c (expand_vector_operations_1): Check
> >>>         optab exists before use it.
> >>>
> >>> gcc/testsuite/
> >>>
> >>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
> >>>
> >>>         * g++.dg/pr68062.C: New test.
> >>
> >> OK.
> >>
> >> Just curious, what was the tree code for which we couldn't find a suitable
> >> optab?
> >
> > Those are various comparison codes.
> 
> Yeah, sorry for missing that check.  Btw, I was curious to see that we miss
> a way to query from optab_tag the "kind" (normal, conversion, etc.) so code
> can decide what optab_handler function to call (optab_handler or
> convert_optab_handler).  So the code I added errs on the "simplistic" side
> and hopes that matching lhs and rhs1 type always gets us a non-convert optab...

So probably better fix is

diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index d1fc0ba..73c5cc5 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -1533,7 +1533,8 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
       && TYPE_MODE (TREE_TYPE (type)) == TYPE_MODE (TREE_TYPE (srhs1)))
     {
       op = optab_for_tree_code (code, TREE_TYPE (type), optab_scalar);
-      if (optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
+      if (op >= FIRST_NORM_OPTAB && op <= LAST_NORM_OPTAB
+	  && optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
 	{
 	  tree slhs = make_ssa_name (TREE_TYPE (srhs1));
 	  gimple *repl = gimple_build_assign (slhs, code, srhs1, srhs2);

?

Ilya

> 
> Richard.
> 
> > Ilya
> >
> >>
> >> jeff
> >>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, PR68062] Fix uniform vector operation lowering
  2015-10-26  9:36       ` Ilya Enkovich
@ 2015-10-26  9:56         ` Richard Biener
  2015-10-26 10:17           ` Ilya Enkovich
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Biener @ 2015-10-26  9:56 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Jeff Law, gcc-patches

On Mon, Oct 26, 2015 at 10:35 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> On 26 Oct 10:09, Richard Biener wrote:
>> On Sat, Oct 24, 2015 at 12:29 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> > 2015-10-24 0:32 GMT+03:00 Jeff Law <law@redhat.com>:
>> >> On 10/23/2015 09:26 AM, Ilya Enkovich wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> This patch checks optab exists before using it vector vector statement
>> >>> lowering.  It fixes compilation of test from PR68062 with -funsigned-char
>> >>> option added (doesn't fix original testcase).  Bootstrapped for
>> >>> x86_64-unknown-linux-gnu.  OK for trunk if no regressions?
>> >>>
>> >>> Thanks,
>> >>> Ilya
>> >>> --
>> >>> gcc/
>> >>>
>> >>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
>> >>>
>> >>>         * tree-vect-generic.c (expand_vector_operations_1): Check
>> >>>         optab exists before use it.
>> >>>
>> >>> gcc/testsuite/
>> >>>
>> >>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
>> >>>
>> >>>         * g++.dg/pr68062.C: New test.
>> >>
>> >> OK.
>> >>
>> >> Just curious, what was the tree code for which we couldn't find a suitable
>> >> optab?
>> >
>> > Those are various comparison codes.
>>
>> Yeah, sorry for missing that check.  Btw, I was curious to see that we miss
>> a way to query from optab_tag the "kind" (normal, conversion, etc.) so code
>> can decide what optab_handler function to call (optab_handler or
>> convert_optab_handler).  So the code I added errs on the "simplistic" side
>> and hopes that matching lhs and rhs1 type always gets us a non-convert optab...
>
> So probably better fix is
>
> diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
> index d1fc0ba..73c5cc5 100644
> --- a/gcc/tree-vect-generic.c
> +++ b/gcc/tree-vect-generic.c
> @@ -1533,7 +1533,8 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
>        && TYPE_MODE (TREE_TYPE (type)) == TYPE_MODE (TREE_TYPE (srhs1)))
>      {
>        op = optab_for_tree_code (code, TREE_TYPE (type), optab_scalar);
> -      if (optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
> +      if (op >= FIRST_NORM_OPTAB && op <= LAST_NORM_OPTAB
> +         && optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
>         {
>           tree slhs = make_ssa_name (TREE_TYPE (srhs1));
>           gimple *repl = gimple_build_assign (slhs, code, srhs1, srhs2);
>
> ?

Ah, didn't know we have those constants - yes, that's a better fix.
After all we want
optab_handler to return sth sensible for it.

Thanks,
Richard.

> Ilya
>
>>
>> Richard.
>>
>> > Ilya
>> >
>> >>
>> >> jeff
>> >>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, PR68062] Fix uniform vector operation lowering
  2015-10-26  9:56         ` Richard Biener
@ 2015-10-26 10:17           ` Ilya Enkovich
  0 siblings, 0 replies; 7+ messages in thread
From: Ilya Enkovich @ 2015-10-26 10:17 UTC (permalink / raw)
  To: Richard Biener; +Cc: Jeff Law, gcc-patches

On 26 Oct 10:56, Richard Biener wrote:
> On Mon, Oct 26, 2015 at 10:35 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> > On 26 Oct 10:09, Richard Biener wrote:
> >> On Sat, Oct 24, 2015 at 12:29 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> >> > 2015-10-24 0:32 GMT+03:00 Jeff Law <law@redhat.com>:
> >> >> On 10/23/2015 09:26 AM, Ilya Enkovich wrote:
> >> >>>
> >> >>> Hi,
> >> >>>
> >> >>> This patch checks optab exists before using it vector vector statement
> >> >>> lowering.  It fixes compilation of test from PR68062 with -funsigned-char
> >> >>> option added (doesn't fix original testcase).  Bootstrapped for
> >> >>> x86_64-unknown-linux-gnu.  OK for trunk if no regressions?
> >> >>>
> >> >>> Thanks,
> >> >>> Ilya
> >> >>> --
> >> >>> gcc/
> >> >>>
> >> >>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
> >> >>>
> >> >>>         * tree-vect-generic.c (expand_vector_operations_1): Check
> >> >>>         optab exists before use it.
> >> >>>
> >> >>> gcc/testsuite/
> >> >>>
> >> >>> 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
> >> >>>
> >> >>>         * g++.dg/pr68062.C: New test.
> >> >>
> >> >> OK.
> >> >>
> >> >> Just curious, what was the tree code for which we couldn't find a suitable
> >> >> optab?
> >> >
> >> > Those are various comparison codes.
> >>
> >> Yeah, sorry for missing that check.  Btw, I was curious to see that we miss
> >> a way to query from optab_tag the "kind" (normal, conversion, etc.) so code
> >> can decide what optab_handler function to call (optab_handler or
> >> convert_optab_handler).  So the code I added errs on the "simplistic" side
> >> and hopes that matching lhs and rhs1 type always gets us a non-convert optab...
> >
> > So probably better fix is
> >
> > diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
> > index d1fc0ba..73c5cc5 100644
> > --- a/gcc/tree-vect-generic.c
> > +++ b/gcc/tree-vect-generic.c
> > @@ -1533,7 +1533,8 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
> >        && TYPE_MODE (TREE_TYPE (type)) == TYPE_MODE (TREE_TYPE (srhs1)))
> >      {
> >        op = optab_for_tree_code (code, TREE_TYPE (type), optab_scalar);
> > -      if (optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
> > +      if (op >= FIRST_NORM_OPTAB && op <= LAST_NORM_OPTAB
> > +         && optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
> >         {
> >           tree slhs = make_ssa_name (TREE_TYPE (srhs1));
> >           gimple *repl = gimple_build_assign (slhs, code, srhs1, srhs2);
> >
> > ?
> 
> Ah, didn't know we have those constants - yes, that's a better fix.
> After all we want
> optab_handler to return sth sensible for it.

I'll install it then.  Here is a version rebased on trunk.

Thanks,
Ilya
--
gcc/

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

	* tree-vect-generic.c (expand_vector_operations_1): Check
	optab type before using it.


diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index 9c59402..a376ca2 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -1533,7 +1533,7 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
       && TYPE_MODE (TREE_TYPE (type)) == TYPE_MODE (TREE_TYPE (srhs1)))
     {
       op = optab_for_tree_code (code, TREE_TYPE (type), optab_scalar);
-      if (op != unknown_optab
+      if (op >= FIRST_NORM_OPTAB && op <= LAST_NORM_OPTAB
 	  && optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
 	{
 	  tree slhs = make_ssa_name (TREE_TYPE (srhs1));

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-26 10:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-23 15:32 [PATCH, PR68062] Fix uniform vector operation lowering Ilya Enkovich
2015-10-23 22:23 ` Jeff Law
2015-10-23 22:34   ` Ilya Enkovich
2015-10-26  9:11     ` Richard Biener
2015-10-26  9:36       ` Ilya Enkovich
2015-10-26  9:56         ` Richard Biener
2015-10-26 10:17           ` Ilya Enkovich

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