public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFA] [PowerPC]
@ 2011-04-19 19:19 edmar
  2011-04-21  5:28 ` Segher Boessenkool
  0 siblings, 1 reply; 3+ messages in thread
From: edmar @ 2011-04-19 19:19 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 905 bytes --]

This patch fixes some test cases for PowerPC.

The tests pr39902-2.c, dfp-dd.c, and dfp-td.c reports as errors
when gcc is configured without dfp support. This patch will make the
tests to be reported as unsupported.

The test and-1.c has wrong logic.
In the formula:
y & ~(y & -y)

The part (y & -y) is always a mask with one bit set, which corresponds
to the least significant "1" bit in y.
The final result is that bit, is set to zero (y & ~mask)

There is no boolean simplification possible, and the compiler always 
produces
a nand instruction.

The test should be:
y & ~(y & ~x)

Which can be simplified to:
y & (~y or x)
y.~y or yx
yx

Optimized code has a single "and" instruction. Sub-optimal optimization
will generate a "nand" or an "orc" / "and" pair (as in gcc-4.3).


I also would like to request for someone to commit the patch after
approval, as I have no WAA privileges.

Regards,
Edmar


[-- Attachment #2: sub_ppc_testcases-Changelog-testsuite --]
[-- Type: text/plain, Size: 250 bytes --]

2011-04-19  Edmar Wienskoski  edmar@freescale.com

	* gcc.target/powerpc/pr39902-2.c: Skip testcase for non-dfp
	targets.
	* gcc.target/powerpc/dfp-dd.c: ditto
	* gcc.target/powerpc/dfp-td.c: ditto
	* gcc.target/powerpc/and-1.c: Fixed testcase logic

[-- Attachment #3: sub_ppc_testcases.diff --]
[-- Type: text/x-patch, Size: 2651 bytes --]

Index: gcc-20100630/gcc/testsuite/gcc.target/powerpc/pr39902-2.c
===================================================================
--- gcc-20100630/gcc/testsuite/gcc.target/powerpc/pr39902-2.c	(revision 161589)
+++ gcc-20100630/gcc/testsuite/gcc.target/powerpc/pr39902-2.c	(working copy)
@@ -1,7 +1,7 @@
 /* Check that simplification "x*(-1)" -> "-x" is not performed for decimal
    float types.  */
 
-/* { dg-do compile { target { powerpc*-*-linux* && powerpc_fprs } } } */
+/* { dg-do compile { target { powerpc*-*-linux* && { powerpc_fprs && dfp } } } } */
 /* { dg-options "-std=gnu99 -O -mcpu=power6" } */
 /* { dg-final { scan-assembler-not "fneg" } } */
 
Index: gcc-20100630/gcc/testsuite/gcc.target/powerpc/dfp-dd.c
===================================================================
--- gcc-20100630/gcc/testsuite/gcc.target/powerpc/dfp-dd.c	(revision 161589)
+++ gcc-20100630/gcc/testsuite/gcc.target/powerpc/dfp-dd.c	(working copy)
@@ -1,6 +1,6 @@
 /* Test generation of DFP instructions for POWER6.  */
 /* Origin: Janis Johnson <janis187@us.ibm.com> */
-/* { dg-do compile { target { powerpc*-*-linux* && powerpc_fprs } } } */
+/* { dg-do compile { target { powerpc*-*-linux* && { powerpc_fprs && dfp } } } } */
 /* { dg-options "-std=gnu99 -mcpu=power6" } */
 
 /* { dg-final { scan-assembler "dadd" } } */
Index: gcc-20100630/gcc/testsuite/gcc.target/powerpc/dfp-td.c
===================================================================
--- gcc-20100630/gcc/testsuite/gcc.target/powerpc/dfp-td.c	(revision 161589)
+++ gcc-20100630/gcc/testsuite/gcc.target/powerpc/dfp-td.c	(working copy)
@@ -1,6 +1,6 @@
 /* Test generation of DFP instructions for POWER6.  */
 /* Origin: Janis Johnson <janis187@us.ibm.com> */
-/* { dg-do compile { target { powerpc*-*-linux* && powerpc_fprs } } } */
+/* { dg-do compile { target { powerpc*-*-linux* && { powerpc_fprs && dfp } } } } */
 /* { dg-options "-std=gnu99 -mcpu=power6" } */
 
 /* { dg-final { scan-assembler "daddq" } } */
Index: gcc-20100630/gcc/testsuite/gcc.dg/and-1.c
===================================================================
--- gcc-20100630/gcc/testsuite/gcc.dg/and-1.c	(revision 161589)
+++ gcc-20100630/gcc/testsuite/gcc.dg/and-1.c	(working copy)
@@ -3,8 +3,9 @@
 /* { dg-final { scan-assembler "and" { target powerpc*-*-* spu-*-* } } } */
 /* There should be no nand for this testcase (for either PPC or SPU). */
 /* { dg-final { scan-assembler-not "nand" { target powerpc*-*-* spu-*-* } } } */
+/* { dg-final { scan-assembler-not "orc" { target powerpc*-*-* spu-*-* } } } */
 
-int f(int y)
+int f(int y, int x)
 {
-  return y & ~(y & -y);
+  return y & ~(y & ~x);
 }

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

* Re: [RFA] [PowerPC]
  2011-04-19 19:19 [RFA] [PowerPC] edmar
@ 2011-04-21  5:28 ` Segher Boessenkool
  2011-04-21 15:53   ` edmar
  0 siblings, 1 reply; 3+ messages in thread
From: Segher Boessenkool @ 2011-04-21  5:28 UTC (permalink / raw)
  To: edmar; +Cc: gcc-patches

> The test and-1.c has wrong logic.
> In the formula:
> y & ~(y & -y)
>
> The part (y & -y) is always a mask with one bit set, which corresponds
> to the least significant "1" bit in y.
> The final result is that bit, is set to zero (y & ~mask)
>
> There is no boolean simplification possible, and the compiler always 
> produces
> a nand instruction.

The formula is equal to  y & (y-1) , maybe the testcase is testing that?


Segher

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

* Re: [RFA] [PowerPC]
  2011-04-21  5:28 ` Segher Boessenkool
@ 2011-04-21 15:53   ` edmar
  0 siblings, 0 replies; 3+ messages in thread
From: edmar @ 2011-04-21 15:53 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-patches

On 04/20/2011 07:52 PM, Segher Boessenkool wrote:
>> The test and-1.c has wrong logic.
>> In the formula:
>> y & ~(y & -y)
>>
>> The part (y & -y) is always a mask with one bit set, which corresponds
>> to the least significant "1" bit in y.
>> The final result is that bit, is set to zero (y & ~mask)
>>
>> There is no boolean simplification possible, and the compiler always 
>> produces
>> a nand instruction.
>
> The formula is equal to  y & (y-1) , maybe the testcase is testing that?
>
>
> Segher
>
>
>
Ah, yes
A neg/nand/and should be optimized into a sub -1/and.

I will check why this is not happening.

Thanks
Edmar


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

end of thread, other threads:[~2011-04-21 15:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-19 19:19 [RFA] [PowerPC] edmar
2011-04-21  5:28 ` Segher Boessenkool
2011-04-21 15:53   ` edmar

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