This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to rs6000_rtx_costs
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 1 Nov 2005 13:31:14 +0000 (UTC)
- Subject: Patch to rs6000_rtx_costs
This patch corrects a problem with the handling of MULT inside PLUS or
MINUS in rs6000_rtx_costs which showed up in implementing support for
the IBM PowerPC 405 and 440 half-word multiply-accumulate
instructions.
It's wrong to count the costs of an inner instruction and then return
false to indicate the caller should count them as well. The bug meant
that multiply-accumulate instructions (as present on 4xx) were
considered to cost *more* than their constituent operations. With
this patch, they are considered to cost the same as their consituent
operations, which will allow combine to combine them on processors
with a suitable multiply-accumulate operation.
The problem appears to have been introduced by the combination of
r85488 | dje | 2004-08-03 15:31:38 +0000 (Tue, 03 Aug 2004) | 5 lines
* config/rs6000/rs6000.c (rs6000_rtx_costs): Calculate cost of
constants more accurately. Adjust costs for FMA instructions.
Add cases for most logical and float operations. Recurse into
most operands.
making the function return false, with
r84556 | sayle | 2004-07-12 13:42:28 +0000 (Mon, 12 Jul 2004) | 5 lines
* config/rs6000/rs6000.c (rs6000_rtx_costs): Indicate that the
rs6000 doesn't have shift-and-add or shift-and-sub instructions
by returning the cost of a multiplication plus an addition.
which added the special case code.
(I don't have a testcase showing the issue without the separate patch
- to be submitted for 4.2 - which adds support for the new
instructions, but the issue appears to be a regression from when the
logic was correct between the two patches identified there. If the
bug has any effect on current code generation then I'd expect this
patch to improve things.)
Bootstrapped with no regressions on powerpc64-unknown-linux-gnu.
Applied to csl-ppc4xx-branch. OK to commit to mainline as a
regression fix?
2005-11-01 Joseph S. Myers <joseph@codesourcery.com>
* config/rs6000/rs6000.c (rs6000_rtx_costs): Do not add extra
costs for MULT inside PLUS or MINUS.
diff -rupN GCC.orig/gcc/config/rs6000/rs6000.c GCC/gcc/config/rs6000/rs6000.c
--- GCC.orig/gcc/config/rs6000/rs6000.c 2005-10-28 23:33:48.000000000 +0000
+++ GCC/gcc/config/rs6000/rs6000.c 2005-10-30 00:43:55.000000000 +0000
@@ -18304,12 +18304,6 @@ rs6000_rtx_costs (rtx x, int code, int o
else
*total = rs6000_cost->fp;
}
- else if (GET_CODE (XEXP (x, 0)) == MULT)
- {
- /* The rs6000 doesn't have shift-and-add instructions. */
- rs6000_rtx_costs (XEXP (x, 0), MULT, PLUS, total);
- *total += COSTS_N_INSNS (1);
- }
else
*total = COSTS_N_INSNS (1);
return false;
@@ -18336,12 +18330,6 @@ rs6000_rtx_costs (rtx x, int code, int o
else
*total = rs6000_cost->fp;
}
- else if (GET_CODE (XEXP (x, 0)) == MULT)
- {
- /* The rs6000 doesn't have shift-and-sub instructions. */
- rs6000_rtx_costs (XEXP (x, 0), MULT, MINUS, total);
- *total += COSTS_N_INSNS (1);
- }
else
*total = COSTS_N_INSNS (1);
return false;
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
joseph@codesourcery.com (CodeSourcery mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)