* [Patch] omp-grid.c – add cast to silence different enumeration types warning
@ 2020-04-03 9:02 Tobias Burnus
2020-04-03 9:08 ` Jakub Jelinek
0 siblings, 1 reply; 5+ messages in thread
From: Tobias Burnus @ 2020-04-03 9:02 UTC (permalink / raw)
To: gcc-patches, Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 1570 bytes --]
Hi,
that's based on https://users.suse.com/~mliska/clang-warnings.txt
which has for omp-grid.c:
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang/build/gcc/omp-grid.c:1070:7: warning: comparison of two values with different enumeration types in switch statement ('enum tree_code' and 'omp_clause_code') [-Wenum-compare-switch]
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang/build/gcc/omp-grid.c:1081:7: warning: comparison of two values with different enumeration types in switch statement ('enum tree_code' and 'omp_clause_code') [-Wenum-compare-switch]
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang/build/gcc/omp-grid.c:1082:7: warning: comparison of two values with different enumeration types in switch statement ('enum tree_code' and 'omp_clause_code') [-Wenum-compare-switch]
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang/build/gcc/omp-grid.c:1083:7: warning: comparison of two values with different enumeration types in switch statement ('enum tree_code' and 'omp_clause_code') [-Wenum-compare-switch]
Those are all for the same switch statement;
gomp_for contains 'tree clauses' and this clauses's '->code' is used
to handle store 'enum omp_clauses_code' values in in gimple.{h,c}.
I think adding this cast (and only this one) makes sense and it
also silences a (clang) compiler warning.
OK?
Tobias
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
[-- Attachment #2: omp-warn.diff --]
[-- Type: text/x-patch, Size: 1082 bytes --]
omp-grid.c – add cast to silence different enumeration types warning
* omp-grid.c (grid_eliminate_combined_simd_part): Add cast
to omp_clause_code to silence compiler warning.
diff --git a/gcc/omp-grid.c b/gcc/omp-grid.c
index b98e45de6a0..878977da2f9 100644
--- a/gcc/omp-grid.c
+++ b/gcc/omp-grid.c
@@ -1058,21 +1058,21 @@ grid_eliminate_combined_simd_part (gomp_for *parloop)
while (*tgt)
tgt = &OMP_CLAUSE_CHAIN (*tgt);
/* Copy over all clauses, except for linear clauses, which are turned into
private clauses, and all other simd-specific clauses, which are
ignored. */
tree *pc = gimple_omp_for_clauses_ptr (simd);
while (*pc)
{
tree c = *pc;
- switch (TREE_CODE (c))
+ switch ((omp_clause_code) TREE_CODE (c))
{
case OMP_CLAUSE_LINEAR:
{
tree priv = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (priv) = OMP_CLAUSE_DECL (c);
OMP_CLAUSE_CHAIN (priv) = NULL;
*tgt = priv;
tgt = &OMP_CLAUSE_CHAIN (priv);
pc = &OMP_CLAUSE_CHAIN (c);
break;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] omp-grid.c – add cast to silence different enumeration types warning
2020-04-03 9:02 [Patch] omp-grid.c – add cast to silence different enumeration types warning Tobias Burnus
@ 2020-04-03 9:08 ` Jakub Jelinek
2020-04-03 10:43 ` [Patch] HSA: omp-grid.c – access proper clause code (was: Re: [Patch] omp-grid.c – add cast to silence different enumeration types warning) Tobias Burnus
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2020-04-03 9:08 UTC (permalink / raw)
To: Tobias Burnus, Martin Jambor; +Cc: gcc-patches
On Fri, Apr 03, 2020 at 11:02:13AM +0200, Tobias Burnus wrote:
> Those are all for the same switch statement;
>
> gomp_for contains 'tree clauses' and this clauses's '->code' is used
> to handle store 'enum omp_clauses_code' values in in gimple.{h,c}.
>
> I think adding this cast (and only this one) makes sense and it
> also silences a (clang) compiler warning.
That looks wrong to me. If *pc are OMP_CLAUSES, then it should use
OMP_CLAUSE_CODE (c) instead of TREE_CODE (c).
If something creates a tree that has TREE_CODE OMP_CLAUSE_LINEAR, then
that looks very suspicios (TREE_CODE should be OMP_CLAUSE).
> omp-grid.c – add cast to silence different enumeration types warning
>
> * omp-grid.c (grid_eliminate_combined_simd_part): Add cast
> to omp_clause_code to silence compiler warning.
>
> diff --git a/gcc/omp-grid.c b/gcc/omp-grid.c
> index b98e45de6a0..878977da2f9 100644
> --- a/gcc/omp-grid.c
> +++ b/gcc/omp-grid.c
> @@ -1058,21 +1058,21 @@ grid_eliminate_combined_simd_part (gomp_for *parloop)
> while (*tgt)
> tgt = &OMP_CLAUSE_CHAIN (*tgt);
>
> /* Copy over all clauses, except for linear clauses, which are turned into
> private clauses, and all other simd-specific clauses, which are
> ignored. */
> tree *pc = gimple_omp_for_clauses_ptr (simd);
> while (*pc)
> {
> tree c = *pc;
> - switch (TREE_CODE (c))
> + switch ((omp_clause_code) TREE_CODE (c))
> {
> case OMP_CLAUSE_LINEAR:
> {
> tree priv = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE_PRIVATE);
> OMP_CLAUSE_DECL (priv) = OMP_CLAUSE_DECL (c);
> OMP_CLAUSE_CHAIN (priv) = NULL;
> *tgt = priv;
> tgt = &OMP_CLAUSE_CHAIN (priv);
> pc = &OMP_CLAUSE_CHAIN (c);
> break;
Jakub
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Patch] HSA: omp-grid.c – access proper clause code (was: Re: [Patch] omp-grid.c – add cast to silence different enumeration types warning)
2020-04-03 9:08 ` Jakub Jelinek
@ 2020-04-03 10:43 ` Tobias Burnus
2020-04-06 12:32 ` Jakub Jelinek
0 siblings, 1 reply; 5+ messages in thread
From: Tobias Burnus @ 2020-04-03 10:43 UTC (permalink / raw)
To: Jakub Jelinek, Martin Jambor; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2904 bytes --]
Hi Jakub, hi Martin,
I think I misread some bits – after more code reading, I think it
correctly sets '(NODE)->omp_clause.code' alias OMP_CLAUSE_CODE;
Hence, using OMP_CLAUSE_CODE in the switch statement makes sense
for the actual code usage (and, of course, also semantically).
As I don't have HSA setup, I couldn't test it. This code is only
called via omp-low.c's execute_lower_omp via:
if (hsa_gen_requested_p ())
omp_grid_gridify_all_targets (&body);
Hence, unsurprisingly, it did not make a difference when running
the testsuite .
OK?
[The code was added (back then to omp-low.c) in
commit 56b1c60e412fcf1245b4780871553cbdebb956a3 (r242761) with
Martins' [plural ;-)] 'Merge from HSA branch to trunk'.]
Tobias
On 4/3/20 11:08 AM, Jakub Jelinek wrote:
> On Fri, Apr 03, 2020 at 11:02:13AM +0200, Tobias Burnus wrote:
>> Those are all for the same switch statement;
>>
>> gomp_for contains 'tree clauses' and this clauses's '->code' is used
>> to handle store 'enum omp_clauses_code' values in in gimple.{h,c}.
>>
>> I think adding this cast (and only this one) makes sense and it
>> also silences a (clang) compiler warning.
> That looks wrong to me. If *pc are OMP_CLAUSES, then it should use
> OMP_CLAUSE_CODE (c) instead of TREE_CODE (c).
> If something creates a tree that has TREE_CODE OMP_CLAUSE_LINEAR, then
> that looks very suspicios (TREE_CODE should be OMP_CLAUSE).
>
>> omp-grid.c – add cast to silence different enumeration types warning
>>
>> * omp-grid.c (grid_eliminate_combined_simd_part): Add cast
>> to omp_clause_code to silence compiler warning.
>>
>> diff --git a/gcc/omp-grid.c b/gcc/omp-grid.c
>> index b98e45de6a0..878977da2f9 100644
>> --- a/gcc/omp-grid.c
>> +++ b/gcc/omp-grid.c
>> @@ -1058,21 +1058,21 @@ grid_eliminate_combined_simd_part (gomp_for *parloop)
>> while (*tgt)
>> tgt = &OMP_CLAUSE_CHAIN (*tgt);
>>
>> /* Copy over all clauses, except for linear clauses, which are turned into
>> private clauses, and all other simd-specific clauses, which are
>> ignored. */
>> tree *pc = gimple_omp_for_clauses_ptr (simd);
>> while (*pc)
>> {
>> tree c = *pc;
>> - switch (TREE_CODE (c))
>> + switch ((omp_clause_code) TREE_CODE (c))
>> {
>> case OMP_CLAUSE_LINEAR:
>> {
>> tree priv = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE_PRIVATE);
>> OMP_CLAUSE_DECL (priv) = OMP_CLAUSE_DECL (c);
>> OMP_CLAUSE_CHAIN (priv) = NULL;
>> *tgt = priv;
>> tgt = &OMP_CLAUSE_CHAIN (priv);
>> pc = &OMP_CLAUSE_CHAIN (c);
>> break;
>
> Jakub
>
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
[-- Attachment #2: omp-warn-v2.diff --]
[-- Type: text/x-patch, Size: 497 bytes --]
HSA: omp-grid.c – access proper clause code
* omp-grid.c (grid_eliminate_combined_simd_part): Use
OMP_CLAUSE_CODE to access the omp clause code.
diff --git a/gcc/omp-grid.c b/gcc/omp-grid.c
index b98e45de6a0..ba635fd3ea2 100644
--- a/gcc/omp-grid.c
+++ b/gcc/omp-grid.c
@@ -1065,7 +1065,7 @@ grid_eliminate_combined_simd_part (gomp_for *parloop)
while (*pc)
{
tree c = *pc;
- switch (TREE_CODE (c))
+ switch (OMP_CLAUSE_CODE (c))
{
case OMP_CLAUSE_LINEAR:
{
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] HSA: omp-grid.c – access proper clause code (was: Re: [Patch] omp-grid.c – add cast to silence different enumeration types warning)
2020-04-03 10:43 ` [Patch] HSA: omp-grid.c – access proper clause code (was: Re: [Patch] omp-grid.c – add cast to silence different enumeration types warning) Tobias Burnus
@ 2020-04-06 12:32 ` Jakub Jelinek
2020-04-09 17:46 ` Martin Jambor
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2020-04-06 12:32 UTC (permalink / raw)
To: Tobias Burnus, Martin Jambor; +Cc: gcc-patches
On Fri, Apr 03, 2020 at 12:43:42PM +0200, Tobias Burnus wrote:
> HSA: omp-grid.c – access proper clause code
>
> * omp-grid.c (grid_eliminate_combined_simd_part): Use
> OMP_CLAUSE_CODE to access the omp clause code.
>
> diff --git a/gcc/omp-grid.c b/gcc/omp-grid.c
> index b98e45de6a0..ba635fd3ea2 100644
> --- a/gcc/omp-grid.c
> +++ b/gcc/omp-grid.c
> @@ -1065,7 +1065,7 @@ grid_eliminate_combined_simd_part (gomp_for *parloop)
> while (*pc)
> {
> tree c = *pc;
> - switch (TREE_CODE (c))
> + switch (OMP_CLAUSE_CODE (c))
> {
> case OMP_CLAUSE_LINEAR:
> {
It looks good to me, but I have no way to actually test it, nor understand
why it worked (or isn't covered by testsuite) in the HSAIL offloading case.
Martin?
Jakub
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] HSA: omp-grid.c – access proper clause code (was: Re: [Patch] omp-grid.c – add cast to silence different enumeration types warning)
2020-04-06 12:32 ` Jakub Jelinek
@ 2020-04-09 17:46 ` Martin Jambor
0 siblings, 0 replies; 5+ messages in thread
From: Martin Jambor @ 2020-04-09 17:46 UTC (permalink / raw)
To: Jakub Jelinek, Tobias Burnus; +Cc: gcc-patches
Hi,
On Mon, Apr 06 2020, Jakub Jelinek wrote:
> On Fri, Apr 03, 2020 at 12:43:42PM +0200, Tobias Burnus wrote:
>> HSA: omp-grid.c – access proper clause code
>>
>> * omp-grid.c (grid_eliminate_combined_simd_part): Use
>> OMP_CLAUSE_CODE to access the omp clause code.
>>
>> diff --git a/gcc/omp-grid.c b/gcc/omp-grid.c
>> index b98e45de6a0..ba635fd3ea2 100644
>> --- a/gcc/omp-grid.c
>> +++ b/gcc/omp-grid.c
>> @@ -1065,7 +1065,7 @@ grid_eliminate_combined_simd_part (gomp_for *parloop)
>> while (*pc)
>> {
>> tree c = *pc;
>> - switch (TREE_CODE (c))
>> + switch (OMP_CLAUSE_CODE (c))
>> {
>> case OMP_CLAUSE_LINEAR:
>> {
>
> It looks good to me, but I have no way to actually test it, nor understand
> why it worked (or isn't covered by testsuite) in the HSAIL offloading case.
> Martin?
>
Yes, most likely the gridification of any tests which should have
covered this bailed out earlier. The patch looks obvious to me.
Thanks for taking care of it.
Martin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-09 17:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 9:02 [Patch] omp-grid.c – add cast to silence different enumeration types warning Tobias Burnus
2020-04-03 9:08 ` Jakub Jelinek
2020-04-03 10:43 ` [Patch] HSA: omp-grid.c – access proper clause code (was: Re: [Patch] omp-grid.c – add cast to silence different enumeration types warning) Tobias Burnus
2020-04-06 12:32 ` Jakub Jelinek
2020-04-09 17:46 ` Martin Jambor
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).