> > -----Original Message----- > From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-ow...@gcc.gnu.org] On > Behalf Of DJ Delorie > Sent: Wednesday, November 02, 2011 11:24 PM > To: gcc-patches@gcc.gnu.org > Subject: expr.c: don't assume MUL for scaling pointers > > > GCC assumes the target has a multiply insn, but better code is generated > using shifts if it doesn't (vs a libcall). Found with the rl78-elf port. > > * expr.c (expand_expr_real_2): Don't try to emit a MUL-based > expression if the target doesn't have a multiply pattern. Fall > back to shifts instead of using libgcc calls.
Does this also work if the target has a multiply pattern but that is only enabled some of the time (for example, depending on the specified -march=xyz value)? What about the case where mul is available but much higher cost than shift? paul