* [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
@ 2015-07-06 8:20 Szabolcs Nagy
2015-07-06 10:24 ` James Greenhalgh
2015-07-06 15:39 ` Marcus Shawcroft
0 siblings, 2 replies; 9+ messages in thread
From: Szabolcs Nagy @ 2015-07-06 8:20 UTC (permalink / raw)
To: gcc-patches; +Cc: Ramana Radhakrishnan, Marcus Shawcroft
[-- Attachment #1: Type: text/plain, Size: 718 bytes --]
fnmul was modeled as (-a)*b instead of -(a*b), which is wrong with
-frounding-math, so the correct pattern is added too and the other
one is only used if !flag_rounding_math.
This affects a glibc math test, similar fix will be needed for ARM.
Tested with aarch64-none-linux-gnu cross compiler.
is this OK?
gcc/Changelog:
2015-07-06 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR target/66731
* config/aarch64/aarch64.md (fnmul<mode>3): Handle -frounding-math.
gcc/testsuite/Changelog:
2015-07-06 Szabolcs Nagy <szabolcs.nagy@arm.com>
* gcc.target/aarch64/fnmul-1.c: New.
* gcc.target/aarch64/fnmul-2.c: New.
* gcc.target/aarch64/fnmul-3.c: New.
* gcc.target/aarch64/fnmul-4.c: New.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fnmul-2.diff --]
[-- Type: text/x-patch; name=fnmul-2.diff, Size: 3274 bytes --]
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 2d56a75..1e343fa 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -4175,6 +4175,16 @@
(mult:GPF
(neg:GPF (match_operand:GPF 1 "register_operand" "w"))
(match_operand:GPF 2 "register_operand" "w")))]
+ "TARGET_FLOAT && !flag_rounding_math"
+ "fnmul\\t%<s>0, %<s>1, %<s>2"
+ [(set_attr "type" "fmul<s>")]
+)
+
+(define_insn "*fnmul<mode>3"
+ [(set (match_operand:GPF 0 "register_operand" "=w")
+ (neg:GPF (mult:GPF
+ (match_operand:GPF 1 "register_operand" "w")
+ (match_operand:GPF 2 "register_operand" "w"))))]
"TARGET_FLOAT"
"fnmul\\t%<s>0, %<s>1, %<s>2"
[(set_attr "type" "fmul<s>")]
diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-1.c b/gcc/testsuite/gcc.target/aarch64/fnmul-1.c
new file mode 100644
index 0000000..7ec38e0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/fnmul-1.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+double
+foo_d (double a, double b)
+{
+ /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
+ return -a * b;
+}
+
+float
+foo_s (float a, float b)
+{
+ /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
+ return -a * b;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-2.c b/gcc/testsuite/gcc.target/aarch64/fnmul-2.c
new file mode 100644
index 0000000..f05ee79
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/fnmul-2.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -frounding-math" } */
+
+double
+foo_d (double a, double b)
+{
+ /* { dg-final { scan-assembler "fneg\\td\[0-9\]+, d\[0-9\]+" } } */
+ /* { dg-final { scan-assembler "fmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
+ return -a * b;
+}
+
+float
+foo_s (float a, float b)
+{
+ /* { dg-final { scan-assembler "fneg\\ts\[0-9\]+, s\[0-9\]+" } } */
+ /* { dg-final { scan-assembler "fmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
+ return -a * b;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-3.c b/gcc/testsuite/gcc.target/aarch64/fnmul-3.c
new file mode 100644
index 0000000..301e9cd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/fnmul-3.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+double
+foo_d (double a, double b)
+{
+ /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
+ return -(a * b);
+}
+
+float
+foo_s (float a, float b)
+{
+ /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
+ return -(a * b);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-4.c b/gcc/testsuite/gcc.target/aarch64/fnmul-4.c
new file mode 100644
index 0000000..9b9bf1b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/fnmul-4.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -frounding-math" } */
+
+double
+foo_d (double a, double b)
+{
+ /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
+ return -(a * b);
+}
+
+float
+foo_s (float a, float b)
+{
+ /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
+ return -(a * b);
+}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
2015-07-06 8:20 [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math Szabolcs Nagy
@ 2015-07-06 10:24 ` James Greenhalgh
2015-07-16 10:11 ` Szabolcs Nagy
2015-07-06 15:39 ` Marcus Shawcroft
1 sibling, 1 reply; 9+ messages in thread
From: James Greenhalgh @ 2015-07-06 10:24 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: gcc-patches, Ramana Radhakrishnan, Marcus Shawcroft
On Mon, Jul 06, 2015 at 09:20:39AM +0100, Szabolcs Nagy wrote:
> fnmul was modeled as (-a)*b instead of -(a*b), which is wrong with
> -frounding-math, so the correct pattern is added too and the other
> one is only used if !flag_rounding_math.
>
> This affects a glibc math test, similar fix will be needed for ARM.
>
> Tested with aarch64-none-linux-gnu cross compiler.
> is this OK?
>
> gcc/Changelog:
>
> 2015-07-06 Szabolcs Nagy <szabolcs.nagy@arm.com>
>
> PR target/66731
> * config/aarch64/aarch64.md (fnmul<mode>3): Handle -frounding-math.
>
> gcc/testsuite/Changelog:
>
> 2015-07-06 Szabolcs Nagy <szabolcs.nagy@arm.com>
>
> * gcc.target/aarch64/fnmul-1.c: New.
> * gcc.target/aarch64/fnmul-2.c: New.
> * gcc.target/aarch64/fnmul-3.c: New.
> * gcc.target/aarch64/fnmul-4.c: New.
OK.
Please make sure in a follow-up patch that the costing logic in
aarch64_rtx_costs also gets updated.
Thanks,
James
> diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
> index 2d56a75..1e343fa 100644
> --- a/gcc/config/aarch64/aarch64.md
> +++ b/gcc/config/aarch64/aarch64.md
> @@ -4175,6 +4175,16 @@
> (mult:GPF
> (neg:GPF (match_operand:GPF 1 "register_operand" "w"))
> (match_operand:GPF 2 "register_operand" "w")))]
> + "TARGET_FLOAT && !flag_rounding_math"
> + "fnmul\\t%<s>0, %<s>1, %<s>2"
> + [(set_attr "type" "fmul<s>")]
> +)
> +
> +(define_insn "*fnmul<mode>3"
> + [(set (match_operand:GPF 0 "register_operand" "=w")
> + (neg:GPF (mult:GPF
> + (match_operand:GPF 1 "register_operand" "w")
> + (match_operand:GPF 2 "register_operand" "w"))))]
> "TARGET_FLOAT"
> "fnmul\\t%<s>0, %<s>1, %<s>2"
> [(set_attr "type" "fmul<s>")]
> diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-1.c b/gcc/testsuite/gcc.target/aarch64/fnmul-1.c
> new file mode 100644
> index 0000000..7ec38e0
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/fnmul-1.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +double
> +foo_d (double a, double b)
> +{
> + /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
> + return -a * b;
> +}
> +
> +float
> +foo_s (float a, float b)
> +{
> + /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
> + return -a * b;
> +}
> diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-2.c b/gcc/testsuite/gcc.target/aarch64/fnmul-2.c
> new file mode 100644
> index 0000000..f05ee79
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/fnmul-2.c
> @@ -0,0 +1,18 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -frounding-math" } */
> +
> +double
> +foo_d (double a, double b)
> +{
> + /* { dg-final { scan-assembler "fneg\\td\[0-9\]+, d\[0-9\]+" } } */
> + /* { dg-final { scan-assembler "fmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
> + return -a * b;
> +}
> +
> +float
> +foo_s (float a, float b)
> +{
> + /* { dg-final { scan-assembler "fneg\\ts\[0-9\]+, s\[0-9\]+" } } */
> + /* { dg-final { scan-assembler "fmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
> + return -a * b;
> +}
> diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-3.c b/gcc/testsuite/gcc.target/aarch64/fnmul-3.c
> new file mode 100644
> index 0000000..301e9cd
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/fnmul-3.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +double
> +foo_d (double a, double b)
> +{
> + /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
> + return -(a * b);
> +}
> +
> +float
> +foo_s (float a, float b)
> +{
> + /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
> + return -(a * b);
> +}
> diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-4.c b/gcc/testsuite/gcc.target/aarch64/fnmul-4.c
> new file mode 100644
> index 0000000..9b9bf1b
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/fnmul-4.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -frounding-math" } */
> +
> +double
> +foo_d (double a, double b)
> +{
> + /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
> + return -(a * b);
> +}
> +
> +float
> +foo_s (float a, float b)
> +{
> + /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
> + return -(a * b);
> +}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
2015-07-06 8:20 [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math Szabolcs Nagy
2015-07-06 10:24 ` James Greenhalgh
@ 2015-07-06 15:39 ` Marcus Shawcroft
2015-07-09 14:40 ` Szabolcs Nagy
1 sibling, 1 reply; 9+ messages in thread
From: Marcus Shawcroft @ 2015-07-06 15:39 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: gcc-patches, Ramana Radhakrishnan, Marcus Shawcroft
On 6 July 2015 at 09:20, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> 2015-07-06 Szabolcs Nagy <szabolcs.nagy@arm.com>
>
> * gcc.target/aarch64/fnmul-1.c: New.
> * gcc.target/aarch64/fnmul-2.c: New.
> * gcc.target/aarch64/fnmul-3.c: New.
> * gcc.target/aarch64/fnmul-4.c: New.
+float
+foo_s (float a, float b)
+{
+ /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+,
s\[0-9\]+" } } */
+ return -(a * b);
+}
Indentation should set at two spaces.
/Marcus
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
2015-07-06 15:39 ` Marcus Shawcroft
@ 2015-07-09 14:40 ` Szabolcs Nagy
2015-07-15 8:34 ` Ramana Radhakrishnan
0 siblings, 1 reply; 9+ messages in thread
From: Szabolcs Nagy @ 2015-07-09 14:40 UTC (permalink / raw)
To: Marcus Shawcroft; +Cc: gcc-patches, Ramana Radhakrishnan, Marcus Shawcroft
[-- Attachment #1: Type: text/plain, Size: 903 bytes --]
On 06/07/15 16:39, Marcus Shawcroft wrote:
> On 6 July 2015 at 09:20, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>
>> 2015-07-06 Szabolcs Nagy <szabolcs.nagy@arm.com>
>>
>> * gcc.target/aarch64/fnmul-1.c: New.
>> * gcc.target/aarch64/fnmul-2.c: New.
>> * gcc.target/aarch64/fnmul-3.c: New.
>> * gcc.target/aarch64/fnmul-4.c: New.
>
> +float
> +foo_s (float a, float b)
> +{
> + /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+,
> s\[0-9\]+" } } */
> + return -(a * b);
> +}
>
> Indentation should set at two spaces.
> /Marcus
Committed the indentation fix as obvious in r225613.
2015-07-09 Szabolcs Nagy <szabolcs.nagy@arm.com>
* gcc.target/aarch64/fnmul-1.c: Fix whitespace.
* gcc.target/aarch64/fnmul-2.c: Likewise.
* gcc.target/aarch64/fnmul-3.c: Likewise.
* gcc.target/aarch64/fnmul-4.c: Likewise.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fnmul-space.diff --]
[-- Type: text/x-patch; name=fnmul-space.diff, Size: 3306 bytes --]
diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-1.c b/gcc/testsuite/gcc.target/aarch64/fnmul-1.c
index 7ec38e0..92945d4 100644
--- a/gcc/testsuite/gcc.target/aarch64/fnmul-1.c
+++ b/gcc/testsuite/gcc.target/aarch64/fnmul-1.c
@@ -4,13 +4,13 @@
double
foo_d (double a, double b)
{
- /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
- return -a * b;
+ /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
+ return -a * b;
}
float
foo_s (float a, float b)
{
- /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
- return -a * b;
+ /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
+ return -a * b;
}
diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-2.c b/gcc/testsuite/gcc.target/aarch64/fnmul-2.c
index f05ee79..2c80dc8 100644
--- a/gcc/testsuite/gcc.target/aarch64/fnmul-2.c
+++ b/gcc/testsuite/gcc.target/aarch64/fnmul-2.c
@@ -4,15 +4,15 @@
double
foo_d (double a, double b)
{
- /* { dg-final { scan-assembler "fneg\\td\[0-9\]+, d\[0-9\]+" } } */
- /* { dg-final { scan-assembler "fmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
- return -a * b;
+ /* { dg-final { scan-assembler "fneg\\td\[0-9\]+, d\[0-9\]+" } } */
+ /* { dg-final { scan-assembler "fmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
+ return -a * b;
}
float
foo_s (float a, float b)
{
- /* { dg-final { scan-assembler "fneg\\ts\[0-9\]+, s\[0-9\]+" } } */
- /* { dg-final { scan-assembler "fmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
- return -a * b;
+ /* { dg-final { scan-assembler "fneg\\ts\[0-9\]+, s\[0-9\]+" } } */
+ /* { dg-final { scan-assembler "fmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
+ return -a * b;
}
diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-3.c b/gcc/testsuite/gcc.target/aarch64/fnmul-3.c
index 301e9cd..8b77eec 100644
--- a/gcc/testsuite/gcc.target/aarch64/fnmul-3.c
+++ b/gcc/testsuite/gcc.target/aarch64/fnmul-3.c
@@ -4,13 +4,13 @@
double
foo_d (double a, double b)
{
- /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
- return -(a * b);
+ /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
+ return -(a * b);
}
float
foo_s (float a, float b)
{
- /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
- return -(a * b);
+ /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
+ return -(a * b);
}
diff --git a/gcc/testsuite/gcc.target/aarch64/fnmul-4.c b/gcc/testsuite/gcc.target/aarch64/fnmul-4.c
index 9b9bf1b..3306210 100644
--- a/gcc/testsuite/gcc.target/aarch64/fnmul-4.c
+++ b/gcc/testsuite/gcc.target/aarch64/fnmul-4.c
@@ -4,13 +4,13 @@
double
foo_d (double a, double b)
{
- /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
- return -(a * b);
+ /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
+ return -(a * b);
}
float
foo_s (float a, float b)
{
- /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
- return -(a * b);
+ /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
+ return -(a * b);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
2015-07-09 14:40 ` Szabolcs Nagy
@ 2015-07-15 8:34 ` Ramana Radhakrishnan
2015-07-15 9:26 ` Szabolcs Nagy
0 siblings, 1 reply; 9+ messages in thread
From: Ramana Radhakrishnan @ 2015-07-15 8:34 UTC (permalink / raw)
To: gcc-patches
On 09/07/15 15:40, Szabolcs Nagy wrote:
> On 06/07/15 16:39, Marcus Shawcroft wrote:
>> On 6 July 2015 at 09:20, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>
>>> 2015-07-06 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR target/66731 in Changelog ?
Ramana
>>>
>>> * gcc.target/aarch64/fnmul-1.c: New.
>>> * gcc.target/aarch64/fnmul-2.c: New.
>>> * gcc.target/aarch64/fnmul-3.c: New.
>>> * gcc.target/aarch64/fnmul-4.c: New.
>>
>> +float
>> +foo_s (float a, float b)
>> +{
>> + /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+,
>> s\[0-9\]+" } } */
>> + return -(a * b);
>> +}
>>
>> Indentation should set at two spaces.
>> /Marcus
>
> Committed the indentation fix as obvious in r225613.
>
> 2015-07-09 Szabolcs Nagy <szabolcs.nagy@arm.com>
>
> * gcc.target/aarch64/fnmul-1.c: Fix whitespace.
> * gcc.target/aarch64/fnmul-2.c: Likewise.
> * gcc.target/aarch64/fnmul-3.c: Likewise.
> * gcc.target/aarch64/fnmul-4.c: Likewise.
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
2015-07-15 8:34 ` Ramana Radhakrishnan
@ 2015-07-15 9:26 ` Szabolcs Nagy
0 siblings, 0 replies; 9+ messages in thread
From: Szabolcs Nagy @ 2015-07-15 9:26 UTC (permalink / raw)
To: Ramana Radhakrishnan, gcc-patches
On 15/07/15 09:11, Ramana Radhakrishnan wrote:
> On 09/07/15 15:40, Szabolcs Nagy wrote:
>> On 06/07/15 16:39, Marcus Shawcroft wrote:
>>> On 6 July 2015 at 09:20, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>>
>>>> 2015-07-06 Szabolcs Nagy <szabolcs.nagy@arm.com>
>
>
> PR target/66731 in Changelog ?
>
thanks, fixed in r225810.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
2015-07-06 10:24 ` James Greenhalgh
@ 2015-07-16 10:11 ` Szabolcs Nagy
2015-08-04 9:37 ` Szabolcs Nagy
2015-08-04 9:55 ` James Greenhalgh
0 siblings, 2 replies; 9+ messages in thread
From: Szabolcs Nagy @ 2015-07-16 10:11 UTC (permalink / raw)
To: James Greenhalgh; +Cc: gcc-patches, Ramana Radhakrishnan, Marcus Shawcroft
[-- Attachment #1: Type: text/plain, Size: 486 bytes --]
On 06/07/15 11:24, James Greenhalgh wrote:
>
> Please make sure in a follow-up patch that the costing logic in
> aarch64_rtx_costs also gets updated.
>
Tested with aarch64-none-linux-gnu cross compiler.
is this OK?
i assume i should backport the fnmul fixes to the gcc-5 branch.
2015-07-16 Szabolcs Nagy <szabolcs.nagy@arm.com>
* config/aarch64/aarch64.c (aarch64_rtx_costs): Fix NEG cost for FNMUL.
(aarch64_rtx_mult_cost): Fix MULT cost with -frounding-math.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fnmul-cost.diff --]
[-- Type: text/x-patch; name=fnmul-cost.diff, Size: 1398 bytes --]
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 6c13a078..1a3d6be 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -5435,11 +5435,17 @@ aarch64_rtx_mult_cost (rtx x, enum rtx_code code, int outer, bool speed)
if (speed)
{
/* Floating-point FMA/FMUL can also support negations of the
- operands. */
- if (GET_CODE (op0) == NEG)
- op0 = XEXP (op0, 0);
- if (GET_CODE (op1) == NEG)
- op1 = XEXP (op1, 0);
+ operands, unless the rounding mode is upward or downward in
+ which case FNMUL is different than FMUL with operand negation. */
+ bool neg0 = GET_CODE (op0) == NEG;
+ bool neg1 = GET_CODE (op1) == NEG;
+ if (compound_p || !flag_rounding_math || (neg0 && neg1))
+ {
+ if (neg0)
+ op0 = XEXP (op0, 0);
+ if (neg1)
+ op1 = XEXP (op1, 0);
+ }
if (compound_p)
/* FMADD/FNMADD/FNMSUB/FMSUB. */
@@ -5956,6 +5962,12 @@ aarch64_rtx_costs (rtx x, machine_mode mode, int outer ATTRIBUTE_UNUSED,
*cost = rtx_cost (op0, mode, NEG, 0, speed);
return true;
}
+ if (GET_CODE (op0) == MULT)
+ {
+ /* FNMUL. */
+ *cost = rtx_cost (op0, mode, NEG, 0, speed);
+ return true;
+ }
if (speed)
/* FNEG. */
*cost += extra_cost->fp[mode == DFmode].neg;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
2015-07-16 10:11 ` Szabolcs Nagy
@ 2015-08-04 9:37 ` Szabolcs Nagy
2015-08-04 9:55 ` James Greenhalgh
1 sibling, 0 replies; 9+ messages in thread
From: Szabolcs Nagy @ 2015-08-04 9:37 UTC (permalink / raw)
To: James Greenhalgh; +Cc: gcc-patches, Ramana Radhakrishnan, Marcus Shawcroft
On 16/07/15 10:24, Szabolcs Nagy wrote:
> On 06/07/15 11:24, James Greenhalgh wrote:
>>
>> Please make sure in a follow-up patch that the costing logic in
>> aarch64_rtx_costs also gets updated.
>>
>
> Tested with aarch64-none-linux-gnu cross compiler.
> is this OK?
>
> i assume i should backport the fnmul fixes to the gcc-5 branch.
>
> 2015-07-16 Szabolcs Nagy <szabolcs.nagy@arm.com>
>
> * config/aarch64/aarch64.c (aarch64_rtx_costs): Fix NEG cost for FNMUL.
> (aarch64_rtx_mult_cost): Fix MULT cost with -frounding-math.
>
ping.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
2015-07-16 10:11 ` Szabolcs Nagy
2015-08-04 9:37 ` Szabolcs Nagy
@ 2015-08-04 9:55 ` James Greenhalgh
1 sibling, 0 replies; 9+ messages in thread
From: James Greenhalgh @ 2015-08-04 9:55 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: gcc-patches, Ramana Radhakrishnan, Marcus Shawcroft
On Thu, Jul 16, 2015 at 10:24:20AM +0100, Szabolcs Nagy wrote:
> On 06/07/15 11:24, James Greenhalgh wrote:
> >
> > Please make sure in a follow-up patch that the costing logic in
> > aarch64_rtx_costs also gets updated.
> >
>
> Tested with aarch64-none-linux-gnu cross compiler.
> is this OK?
This is OK, sorry for the delay.
> i assume i should backport the fnmul fixes to the gcc-5 branch.
I see the ARM fixes went back to the release branches, so yes, a backport
would be appreciated.
Thanks,
James
>
> 2015-07-16 Szabolcs Nagy <szabolcs.nagy@arm.com>
>
> * config/aarch64/aarch64.c (aarch64_rtx_costs): Fix NEG cost for FNMUL.
> (aarch64_rtx_mult_cost): Fix MULT cost with -frounding-math.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-08-04 9:55 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-06 8:20 [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math Szabolcs Nagy
2015-07-06 10:24 ` James Greenhalgh
2015-07-16 10:11 ` Szabolcs Nagy
2015-08-04 9:37 ` Szabolcs Nagy
2015-08-04 9:55 ` James Greenhalgh
2015-07-06 15:39 ` Marcus Shawcroft
2015-07-09 14:40 ` Szabolcs Nagy
2015-07-15 8:34 ` Ramana Radhakrishnan
2015-07-15 9:26 ` Szabolcs Nagy
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).