This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: James Greenhalgh <james dot greenhalgh at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Ramana Radhakrishnan <Ramana dot Radhakrishnan at arm dot com>, Marcus Shawcroft <Marcus dot Shawcroft at arm dot com>
- Date: Thu, 16 Jul 2015 10:24:20 +0100
- Subject: Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math
- Authentication-results: sourceware.org; auth=none
- References: <559A3A57 dot 3050304 at arm dot com> <20150706102438 dot GA2102 at arm dot com>
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.
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;