Patchwork [RFA,PowerPC]

login
register
mail settings
Submitter edmar
Date April 19, 2011, 6:30 p.m.
Message ID <4DADD4DC.4040305@freescale.com>
Download mbox | patch
Permalink /patch/92045/
State New
Headers show

Comments

edmar - April 19, 2011, 6:30 p.m.
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
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
Segher Boessenkool - April 21, 2011, 12:52 a.m.
> 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
edmar - April 21, 2011, 3:27 p.m.
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

Patch

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);
 }