Patchwork RFA: Fix tree-optimization/55524

login
register
mail settings
Submitter Joern Rennecke
Date April 9, 2013, 11:25 a.m.
Message ID <20130409072525.7t4cx69hc0os0c08-nzlynne@webmail.spamcop.net>
Download mbox | patch
Permalink /patch/235050/
State New
Headers show

Comments

Joern Rennecke - April 9, 2013, 11:25 a.m.
Quoting Richard Biener <richard.guenther@gmail.com>:

> On Mon, Apr 8, 2013 at 5:10 PM, Joern Rennecke
> <joern.rennecke@embecosm.com> wrote:
>> This is basically the same patch as attached to the PR, except that I
>> have changed the goto-loop into a do-while loop with a new comment;
>> this caused the need for a lot of reformatting.
>
> Can you please include a testcase that shows the effect of this?

Attached.
FWIW, the assembler is simpler to understand if you add the compilation
option -mfp-mode=round-nearest.
Without the patch, you then get:

_f:
         fmul r1,r1,r3
         mov r3, %low(#-2147483648)
         movt r3, %high(#-2147483648)
         eor r1,r3,r1
         fmadd r1,r0,r2
         mov r0,r1
         rts

And with the patch:

_f:
         fmul r0,r0,r2
         fmsub r0,r1,r3
         rts


>> 2013-04-08  Joern Rennecke  <joern.rennecke@embecosm.com>
>>
>>         * tree-ssa-math-opts.c (mult_to_fma_pass): New file static struct.
>>         (convert_mult_to_fma): In first pass, don't use an fms construct
>>         when we don't have an fms operation, but fmna.
>
> it's fnma I believe.

Oops, yes, typo.  The patch itself has the right spelling.
2013-03-09  Joern Rennecke <joern.rennecke@embecosm.com>

	* gcc.target/epiphany/fnma-1.c: New test.
Richard Guenther - April 9, 2013, 1:50 p.m.
On Tue, Apr 9, 2013 at 1:25 PM, Joern Rennecke
<joern.rennecke@embecosm.com> wrote:
> Quoting Richard Biener <richard.guenther@gmail.com>:
>
>> On Mon, Apr 8, 2013 at 5:10 PM, Joern Rennecke
>> <joern.rennecke@embecosm.com> wrote:
>>>
>>> This is basically the same patch as attached to the PR, except that I
>>> have changed the goto-loop into a do-while loop with a new comment;
>>> this caused the need for a lot of reformatting.
>>
>>
>> Can you please include a testcase that shows the effect of this?
>
>
> Attached.
> FWIW, the assembler is simpler to understand if you add the compilation
> option -mfp-mode=round-nearest.
> Without the patch, you then get:
>
> _f:
>         fmul r1,r1,r3
>         mov r3, %low(#-2147483648)
>         movt r3, %high(#-2147483648)
>         eor r1,r3,r1
>         fmadd r1,r0,r2
>         mov r0,r1
>         rts
>
> And with the patch:
>
> _f:
>         fmul r0,r0,r2
>         fmsub r0,r1,r3
>         rts

This means the iteration doesn't help here.

>
>
>>> 2013-04-08  Joern Rennecke  <joern.rennecke@embecosm.com>
>>>
>>>         * tree-ssa-math-opts.c (mult_to_fma_pass): New file static
>>> struct.
>>>         (convert_mult_to_fma): In first pass, don't use an fms construct
>>>         when we don't have an fms operation, but fmna.
>>
>>
>> it's fnma I believe.
>
>
> Oops, yes, typo.  The patch itself has the right spelling.
>
> 2013-03-09  Joern Rennecke <joern.rennecke@embecosm.com>
>
>         * gcc.target/epiphany/fnma-1.c: New test.
>
> Index: gcc.target/epiphany/fnma-1.c
> ===================================================================
> --- gcc.target/epiphany/fnma-1.c        (revision 0)
> +++ gcc.target/epiphany/fnma-1.c        (working copy)
> @@ -0,0 +1,9 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +/* { dg-final { scan-assembler-times "fmsub\[ \ta-zA-Z0-9\]*," 1 } } */
> +
> +float
> +f (float ar, float ai, float br, float bi)
> +{
> +  return ar * br - ai * bi;
> +}
>

Patch

Index: gcc.target/epiphany/fnma-1.c
===================================================================
--- gcc.target/epiphany/fnma-1.c	(revision 0)
+++ gcc.target/epiphany/fnma-1.c	(working copy)
@@ -0,0 +1,9 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times "fmsub\[ \ta-zA-Z0-9\]*," 1 } } */
+
+float
+f (float ar, float ai, float br, float bi)
+{
+  return ar * br - ai * bi;
+}