Re: [PATCH, rs6000] Correct return value of check_p9modulo_hw_available
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
Re: [PATCH, rs6000] Correct return value of check_p9modulo_hw_available
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
Re: [PATCH, rs6000] Correct return value of check_p9modulo_hw_available
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 > > 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 > }
[PATCH, rs6000] Correct return value of check_p9modulo_hw_available
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 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 }