Fix always true condition in gimplify_adjust_omp_clauses

Message ID 20170810185044.GS17069@redhat.com
State New
Headers show

Commit Message

Marek Polacek Aug. 10, 2017, 6:50 p.m.
My new warning triggered here and said "bitwise comparison always evaluates to
true" and I believe it's right: GOVD_WRITTEN = 131072 which is 10...0000 in
binary, so n->value & GOVD_WRITTEN can never be 1; I suppose 0 was meant to
be used here instead.  Too bad Jakub's away, so he can't confirm.

Bootstrapped/regtested on x86_64-linux and ppc64le-linux, ok for trunk?

2017-08-10  Marek Polacek  <polacek@redhat.com>

	* gimplify.c (gimplify_adjust_omp_clauses): Compare with 0 instead of
	1.


	Marek

Comments

Marek Polacek Aug. 17, 2017, 8:57 a.m. | #1
Ping.

On Thu, Aug 10, 2017 at 08:50:44PM +0200, Marek Polacek wrote:
> My new warning triggered here and said "bitwise comparison always evaluates to
> true" and I believe it's right: GOVD_WRITTEN = 131072 which is 10...0000 in
> binary, so n->value & GOVD_WRITTEN can never be 1; I suppose 0 was meant to
> be used here instead.  Too bad Jakub's away, so he can't confirm.
> 
> Bootstrapped/regtested on x86_64-linux and ppc64le-linux, ok for trunk?
> 
> 2017-08-10  Marek Polacek  <polacek@redhat.com>
> 
> 	* gimplify.c (gimplify_adjust_omp_clauses): Compare with 0 instead of
> 	1.
> 
> diff --git gcc/gimplify.c gcc/gimplify.c
> index 86623e09f5d..e52d7dcddaf 100644
> --- gcc/gimplify.c
> +++ gcc/gimplify.c
> @@ -8915,7 +8915,7 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p,
>  		OMP_CLAUSE_SHARED_READONLY (c) = 1;
>  	      else if (DECL_P (decl)
>  		       && ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
> -			    && (n->value & GOVD_WRITTEN) != 1)
> +			    && (n->value & GOVD_WRITTEN) != 0)
>  			   || (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
>  			       && !OMP_CLAUSE_LINEAR_NO_COPYOUT (c)))
>  		       && omp_shared_to_firstprivate_optimizable_decl_p (decl))

	Marek
Richard Biener Aug. 17, 2017, 9:32 a.m. | #2
On Thu, Aug 17, 2017 at 10:57 AM, Marek Polacek <polacek@redhat.com> wrote:
> Ping.

Ok.

Richard.

> On Thu, Aug 10, 2017 at 08:50:44PM +0200, Marek Polacek wrote:
>> My new warning triggered here and said "bitwise comparison always evaluates to
>> true" and I believe it's right: GOVD_WRITTEN = 131072 which is 10...0000 in
>> binary, so n->value & GOVD_WRITTEN can never be 1; I suppose 0 was meant to
>> be used here instead.  Too bad Jakub's away, so he can't confirm.
>> Bootstrapped/regtested on x86_64-linux and ppc64le-linux, ok for trunk?
>>
>> 2017-08-10  Marek Polacek  <polacek@redhat.com>
>>
>>       * gimplify.c (gimplify_adjust_omp_clauses): Compare with 0 instead of
>>       1.
>>
>> diff --git gcc/gimplify.c gcc/gimplify.c
>> index 86623e09f5d..e52d7dcddaf 100644
>> --- gcc/gimplify.c
>> +++ gcc/gimplify.c
>> @@ -8915,7 +8915,7 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p,
>>               OMP_CLAUSE_SHARED_READONLY (c) = 1;
>>             else if (DECL_P (decl)
>>                      && ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
>> -                         && (n->value & GOVD_WRITTEN) != 1)
>> +                         && (n->value & GOVD_WRITTEN) != 0)
>>                          || (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
>>                              && !OMP_CLAUSE_LINEAR_NO_COPYOUT (c)))
>>                      && omp_shared_to_firstprivate_optimizable_decl_p (decl))
>
>         Marek

Patch

diff --git gcc/gimplify.c gcc/gimplify.c
index 86623e09f5d..e52d7dcddaf 100644
--- gcc/gimplify.c
+++ gcc/gimplify.c
@@ -8915,7 +8915,7 @@  gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p,
 		OMP_CLAUSE_SHARED_READONLY (c) = 1;
 	      else if (DECL_P (decl)
 		       && ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
-			    && (n->value & GOVD_WRITTEN) != 1)
+			    && (n->value & GOVD_WRITTEN) != 0)
 			   || (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
 			       && !OMP_CLAUSE_LINEAR_NO_COPYOUT (c)))
 		       && omp_shared_to_firstprivate_optimizable_decl_p (decl))