public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, rs6000] Correct return value of check_p9modulo_hw_available
@ 2022-08-04  9:55 HAO CHEN GUI
  2022-08-04 11:12 ` Kewen.Lin
  2022-08-04 17:09 ` Segher Boessenkool
  0 siblings, 2 replies; 4+ messages in thread
From: HAO CHEN GUI @ 2022-08-04  9:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner

Hi,
  This patch corrects return value of check_p9modulo_hw_available. It should
return 0 when p9modulo is supported.

  Bootstrapped and tested on powerpc64-linux BE and LE with no regressions.
Is this okay for trunk? Any recommendations? Thanks a lot.

ChangeLog
2022-08-04  Haochen Gui  <guihaoc@linux.ibm.com>

gcc/testsuite/
	* lib/target-supports.exp (check_p9modulo_hw_available): Correct return
	value.


patch.diff
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 4ed7b25b9a4..04a2a8e8659 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2288,7 +2288,7 @@ proc check_p9modulo_hw_available { } {
 		{
 		    int i = 5, j = 3, r = -1;
 		    asm ("modsw %0,%1,%2" : "+r" (r) : "r" (i), "r" (j));
-		    return (r == 2);
+		    return (r != 2);
 		}
 	    } $options
 	}

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

* Re: [PATCH, rs6000] Correct return value of check_p9modulo_hw_available
  2022-08-04  9:55 [PATCH, rs6000] Correct return value of check_p9modulo_hw_available HAO CHEN GUI
@ 2022-08-04 11:12 ` Kewen.Lin
  2022-08-04 17:09 ` Segher Boessenkool
  1 sibling, 0 replies; 4+ messages in thread
From: Kewen.Lin @ 2022-08-04 11:12 UTC (permalink / raw)
  To: HAO CHEN GUI; +Cc: Segher Boessenkool, David, Peter Bergner, gcc-patches

Hi Haochen,

on 2022/8/4 17:55, HAO CHEN GUI wrote:
> Hi,
>   This patch corrects return value of check_p9modulo_hw_available. It should
> return 0 when p9modulo is supported.

Good catch!  There is no case using p9modulo_hw for now, no coverage, sigh...

> 
>   Bootstrapped and tested on powerpc64-linux BE and LE with no regressions.
> Is this okay for trunk? Any recommendations? Thanks a lot.

This patch is OK, thanks!

BR,
Kewen

> 
> ChangeLog
> 2022-08-04  Haochen Gui  <guihaoc@linux.ibm.com>
> 
> gcc/testsuite/
> 	* lib/target-supports.exp (check_p9modulo_hw_available): Correct return
> 	value.
> 
> 
> patch.diff
> diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
> index 4ed7b25b9a4..04a2a8e8659 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -2288,7 +2288,7 @@ proc check_p9modulo_hw_available { } {
>  		{
>  		    int i = 5, j = 3, r = -1;
>  		    asm ("modsw %0,%1,%2" : "+r" (r) : "r" (i), "r" (j));
> -		    return (r == 2);
> +		    return (r != 2);
>  		}
>  	    } $options
>  	}



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

* Re: [PATCH, rs6000] Correct return value of check_p9modulo_hw_available
  2022-08-04  9:55 [PATCH, rs6000] Correct return value of check_p9modulo_hw_available HAO CHEN GUI
  2022-08-04 11:12 ` Kewen.Lin
@ 2022-08-04 17:09 ` Segher Boessenkool
  2022-08-05  3:05   ` HAO CHEN GUI
  1 sibling, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2022-08-04 17:09 UTC (permalink / raw)
  To: HAO CHEN GUI; +Cc: gcc-patches, David, Kewen.Lin, Peter Bergner

Hi!

On Thu, Aug 04, 2022 at 05:55:20PM +0800, HAO CHEN GUI wrote:
>   This patch corrects return value of check_p9modulo_hw_available. It should
> return 0 when p9modulo is supported.

It would be harder to make such mistakes if it used exit() explicitly,
so that the reader is reminded the shell semantics are used here instead
of the C conventions.

> -		    return (r == 2);
> +		    return (r != 2);

so that then would be smth like

	if (r == 2)
		exit (0);
	else
		exit (1);

(which makes the exit code for failure explicit as well).

Terse is good.  Explicit is good as well :-)

(You don't have to make this change here of course, but keep it in mind
for the future :-) )


Segher

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

* Re: [PATCH, rs6000] Correct return value of check_p9modulo_hw_available
  2022-08-04 17:09 ` Segher Boessenkool
@ 2022-08-05  3:05   ` HAO CHEN GUI
  0 siblings, 0 replies; 4+ messages in thread
From: HAO CHEN GUI @ 2022-08-05  3:05 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-patches, David, Kewen.Lin, Peter Bergner

Hi Segher,
  Thanks so much for your explanation. Now I have a clear picture about
the usage of return value. Patch was committed as r13-1971.

Thanks
Gui Haochen


On 5/8/2022 上午 1:09, Segher Boessenkool wrote:
> Hi!
> 
> On Thu, Aug 04, 2022 at 05:55:20PM +0800, HAO CHEN GUI wrote:
>>   This patch corrects return value of check_p9modulo_hw_available. It should
>> return 0 when p9modulo is supported.
> 
> It would be harder to make such mistakes if it used exit() explicitly,
> so that the reader is reminded the shell semantics are used here instead
> of the C conventions.
> 
>> -		    return (r == 2);
>> +		    return (r != 2);
> 
> so that then would be smth like
> 
> 	if (r == 2)
> 		exit (0);
> 	else
> 		exit (1);
> 
> (which makes the exit code for failure explicit as well).
> 
> Terse is good.  Explicit is good as well :-)
> 
> (You don't have to make this change here of course, but keep it in mind
> for the future :-) )
> 
> 
> Segher

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

end of thread, other threads:[~2022-08-05  3:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04  9:55 [PATCH, rs6000] Correct return value of check_p9modulo_hw_available HAO CHEN GUI
2022-08-04 11:12 ` Kewen.Lin
2022-08-04 17:09 ` Segher Boessenkool
2022-08-05  3:05   ` HAO CHEN GUI

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