This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
shift_cost et al
- From: Richard Henderson <rth at redhat dot com>
- To: Roger Sayle <roger at eyesopen dot com>, gcc-patches at gcc dot gnu dot org
- Date: Sat, 10 Jul 2004 02:47:31 -0700
- Subject: shift_cost et al
What we're doing is generating some random rtl, trying to recognize it,
and if we get a match then we accept the result of rtx_cost.
The Problem is that if the target wants to generate rtl a bit different
than what we built, then we leave the cost of a shift at "infinity".
Which brings me to the object lesson:
int foo(int x) { return x << 6; }
on a target that does not implement an SImode shift, but does implement
DImode shifts (e.g. alpha), will result in a series of 6 additions,
never invoking the lshr_optab at all. Similar would be true of any
target that needed clobbers to recognize the shift.
I'm of a mind to simply take the call to recog out. If the rtx_cost
hook for the target is written well, then the shiftadd/shiftsub bits
will be handled correctly. And the rest can be fixed.
Thoughts?
r~
Index: expmed.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expmed.c,v
retrieving revision 1.180
diff -c -p -d -r1.180 expmed.c
*** expmed.c 10 Jul 2004 08:04:56 -0000 1.180
--- expmed.c 10 Jul 2004 09:34:33 -0000
*************** init_expmed (void)
*** 196,213 ****
{
shift_cost[mode][m] = 32000;
XEXP (SET_SRC (shift_pat), 1) = cint[m];
! if (recog (shift_pat, shift_insn, &dummy) >= 0)
! shift_cost[mode][m] = rtx_cost (SET_SRC (shift_pat), SET);
shiftadd_cost[mode][m] = 32000;
XEXP (XEXP (SET_SRC (shiftadd_pat), 0), 1) = pow2[m];
! if (recog (shiftadd_pat, shiftadd_insn, &dummy) >= 0)
! shiftadd_cost[mode][m] = rtx_cost (SET_SRC (shiftadd_pat), SET);
shiftsub_cost[mode][m] = 32000;
XEXP (XEXP (SET_SRC (shiftsub_pat), 0), 1) = pow2[m];
! if (recog (shiftsub_pat, shiftsub_insn, &dummy) >= 0)
! shiftsub_cost[mode][m] = rtx_cost (SET_SRC (shiftsub_pat), SET);
}
}
--- 196,210 ----
{
shift_cost[mode][m] = 32000;
XEXP (SET_SRC (shift_pat), 1) = cint[m];
! shift_cost[mode][m] = rtx_cost (SET_SRC (shift_pat), SET);
shiftadd_cost[mode][m] = 32000;
XEXP (XEXP (SET_SRC (shiftadd_pat), 0), 1) = pow2[m];
! shiftadd_cost[mode][m] = rtx_cost (SET_SRC (shiftadd_pat), SET);
shiftsub_cost[mode][m] = 32000;
XEXP (XEXP (SET_SRC (shiftsub_pat), 0), 1) = pow2[m];
! shiftsub_cost[mode][m] = rtx_cost (SET_SRC (shiftsub_pat), SET);
}
}