public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][expmed] Calculate mult-by-const cost properly in mult_by_coeff_cost
@ 2015-03-16 10:13 Kyrill Tkachov
  2015-03-17 19:11 ` Jeff Law
  2015-04-13 18:18 ` Jeff Law
  0 siblings, 2 replies; 11+ messages in thread
From: Kyrill Tkachov @ 2015-03-16 10:13 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

Hi all,

Eyeballing the mult_by_coeff_cost function I think it has a typo/bug.
It's supposed to return the cost of multiplying by a constant 'coeff'.
It calculates that by taking the cost of a MULT rtx by that constant
and comparing it to the cost of synthesizing that multiplication, and 
returning
the cheapest. However, in the MULT rtx cost calculations it creates
a MULT rtx of two REGs rather than the a REG and the GEN_INT of coeff as 
I would
expect. This patches fixes that in the obvious way.

Tested aarch64-none-elf and bootstrapped on x86_64-linux-gnu.
I'm guessing this is stage 1 material at this point?

Thanks,
Kyrill

2015-03-13  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * expmed.c (mult_by_coeff_cost): Pass CONT_INT rtx to MULT cost
     calculation rather than fake_reg.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: expmed-mult-by-coeff.patch --]
[-- Type: text/x-patch; name=expmed-mult-by-coeff.patch, Size: 807 bytes --]

commit fa230baf4f35d03cf072904dc048ce4ffcf43148
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Thu Mar 12 09:47:06 2015 +0000

    [expmed] Calculate mult-by-const properly in mult_by_coeff_cost

diff --git a/gcc/expmed.c b/gcc/expmed.c
index 0034203..fec9501 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -3285,7 +3285,8 @@ mult_by_coeff_cost (HOST_WIDE_INT coeff, machine_mode mode, bool speed)
   enum mult_variant variant;
 
   rtx fake_reg = gen_raw_REG (mode, LAST_VIRTUAL_REGISTER + 1);
-  max_cost = set_src_cost (gen_rtx_MULT (mode, fake_reg, fake_reg), speed);
+  max_cost = set_src_cost (gen_rtx_MULT (mode, fake_reg, GEN_INT (coeff)),
+			    speed);
   if (choose_mult_variant (mode, coeff, &algorithm, &variant, max_cost))
     return algorithm.cost.cost;
   else

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-04-20 17:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 10:13 [PATCH][expmed] Calculate mult-by-const cost properly in mult_by_coeff_cost Kyrill Tkachov
2015-03-17 19:11 ` Jeff Law
2015-03-18  9:06   ` Kyrill Tkachov
2015-03-18  9:36     ` Bin.Cheng
2015-03-18  9:39       ` Kyrill Tkachov
2015-04-13 18:18 ` Jeff Law
2015-04-14  8:07   ` Kyrill Tkachov
2015-04-15 15:42     ` Jeff Law
2015-04-15 15:47       ` Kyrill Tkachov
2015-04-20  9:28       ` Kyrill Tkachov
2015-04-20 17:51         ` Jeff Law

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).