This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/15239] New: suboptimal mult-by-const expansion cost limit
- From: "l_belev at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Apr 2004 23:46:05 -0000
- Subject: [Bug c/15239] New: suboptimal mult-by-const expansion cost limit
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Look in the file gcc/expmed.c, function expand_mult(). The code
mult_cost = rtx_cost (gen_rtx_MULT (mode, op0, op1), SET);
mult_cost = MIN (12 * add_cost, mult_cost);
calculates the initial cost limit before the recursive search for
a good expansion is invoked.
The problem is that the limiting of the cost with the cost of 12 adds (the
second line) is arbitrary and for some architectures (like pentium4) where
the multiplication is far more expensive than 12 adds, the generated code is
likely to be suboptimal as execution speed.
It would be better if this limit is somehow platform and/or optimizing-level
dependent (i.e. don't limit artificially the expansion for -O3 or higher).
Intel's compiler (icc) doesn't limit the expansion in such a way even
though for some constants it generates rather long sequences of
adds/subs/leas/shls (instead of an imul).
--
Summary: suboptimal mult-by-const expansion cost limit
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: l_belev at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: *
GCC host triplet: *
GCC target triplet: *
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15239