diff mbox series

[2/2,rs6000] Remove mode promotion for pseudos

Message ID 0b09b98f-9058-b627-6778-2d6fe2151ce5@linux.ibm.com
State New
Headers show
Series [1/2,rs6000] Remove mode promotion for pseudos | expand

Commit Message

HAO CHEN GUI May 20, 2021, 9:49 a.m. UTC
Hi,

    The patch removes mode promotion for pseudos on rs6000 target.

    The attachments are the patch diff and change log file.

     Bootstrapped and tested on powerpc64le-linux and powerpc64-linux 
(with both m32 and m64) with no regressions. Is this okay for trunk? Any 
recommendations? Thanks a lot.
rs6000 has instructions that can do almost everything 32 bit
	at least as efficiently as corresponding 64 bit things. The
	mode promotion can be defered to when a wide mode is necessary.
	So it helps a lot not promote mode for pseudos. SPECint test
	shows that the overall performance improvement (by geomean) is
	more than 2% with this patch.
	testsuite/gcc.target/powerpc/not-promote-mode.c illustrates how
	the patch eliminates the redundant extensions and do further
	optimization by disabling mode promotion for pseduos.

	* config/rs6000/rs6000.h (PROMOTE_MODE): Remove.
	* testsuite/gcc.target/powerpc/not-promote-mode.c: New.

Comments

HAO CHEN GUI June 3, 2021, 1:17 a.m. UTC | #1
Hi,

   Gentle ping this:

   https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570854.html

Thanks.

On 20/5/2021 下午 5:49, HAO CHEN GUI wrote:
> Hi,
>
>    The patch removes mode promotion for pseudos on rs6000 target.
>
>    The attachments are the patch diff and change log file.
>
>     Bootstrapped and tested on powerpc64le-linux and powerpc64-linux 
> (with both m32 and m64) with no regressions. Is this okay for trunk? 
> Any recommendations? Thanks a lot.
>
Segher Boessenkool June 3, 2021, 5:36 p.m. UTC | #2
Hi!

On Thu, May 20, 2021 at 05:49:49PM +0800, HAO CHEN GUI wrote:
> 	rs6000 has instructions that can do almost everything 32 bit
> 	at least as efficiently as corresponding 64 bit things. The
> 	mode promotion can be defered to when a wide mode is necessary.
> 	So it helps a lot not promote mode for pseudos. SPECint test
> 	shows that the overall performance improvement (by geomean) is
> 	more than 2% with this patch.
> 	testsuite/gcc.target/powerpc/not-promote-mode.c illustrates how
> 	the patch eliminates the redundant extensions and do further
> 	optimization by disabling mode promotion for pseduos.

I'd still like to see if (and why) this works better than explicitly
promoting QImode and HImode here.  But that can be done later.

> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/not-promote-mode.c
> @@ -0,0 +1,13 @@
> +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */

Just

/* { dg-do compile { target lp64 } } */

because the rest is already implied by this being in gcc.target/powerpc .

The patch is okay for trunk.  Thank you very much for finding this huge
performance gain!


Segher
HAO CHEN GUI June 4, 2021, 8:37 a.m. UTC | #3
Segher,

    I committed two patches (r12-1201 and r12-1202) into trunk. Thanks 
for your review and advice.


On 4/6/2021 上午 1:36, Segher Boessenkool wrote:
> Hi!
>
> On Thu, May 20, 2021 at 05:49:49PM +0800, HAO CHEN GUI wrote:
>> 	rs6000 has instructions that can do almost everything 32 bit
>> 	at least as efficiently as corresponding 64 bit things. The
>> 	mode promotion can be defered to when a wide mode is necessary.
>> 	So it helps a lot not promote mode for pseudos. SPECint test
>> 	shows that the overall performance improvement (by geomean) is
>> 	more than 2% with this patch.
>> 	testsuite/gcc.target/powerpc/not-promote-mode.c illustrates how
>> 	the patch eliminates the redundant extensions and do further
>> 	optimization by disabling mode promotion for pseduos.
> I'd still like to see if (and why) this works better than explicitly
> promoting QImode and HImode here.  But that can be done later.
>
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/not-promote-mode.c
>> @@ -0,0 +1,13 @@
>> +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
> Just
>
> /* { dg-do compile { target lp64 } } */
>
> because the rest is already implied by this being in gcc.target/powerpc .
>
> The patch is okay for trunk.  Thank you very much for finding this huge
> performance gain!
>
>
> Segher
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 233a92baf3c..f6485fcacf5 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -666,17 +666,6 @@  extern unsigned char rs6000_recip_bits[];
 
 /* Target machine storage layout.  */
 
-/* Define this macro if it is advisable to hold scalars in registers
-   in a wider mode than that declared by the program.  In such cases,
-   the value is constrained to be within the bounds of the declared
-   type, but kept valid in the wider mode.  The signedness of the
-   extension may differ from that of the type.  */
-
-#define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE)	\
-  if (GET_MODE_CLASS (MODE) == MODE_INT		\
-      && GET_MODE_SIZE (MODE) < (TARGET_32BIT ? 4 : 8)) \
-    (MODE) = TARGET_32BIT ? SImode : DImode;
-
 /* Define this if most significant bit is lowest numbered
    in instructions that operate on numbered bit-fields.  */
 /* That is true on RS/6000.  */
diff --git a/gcc/testsuite/gcc.target/powerpc/not-promote-mode.c b/gcc/testsuite/gcc.target/powerpc/not-promote-mode.c
new file mode 100644
index 00000000000..4d29ebe8b87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/not-promote-mode.c
@@ -0,0 +1,13 @@ 
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
+/* { dg-options "-O2" } */
+
+extern void bar ();
+
+void foo ()
+{
+  int i;
+  for (i = 0; i < 10000; i++)
+    bar ();
+}
+
+/* { dg-final { scan-assembler-not   {\mrldicl\M} } } */