This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix -fpic cse misses
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 20 May 2002 10:06:19 -0700
- Subject: fix -fpic cse misses
I noticed that no expressions involving the pic register
were being cse'd. The problem is that the expression below
is ordered incorrectly -- %ebx fails because it is
CLASS_LIKELY_SPILLED_P. Which we shouldn't be testing
because the register is fixed with -fpic.
An example of the improvement is
- leal cse_reg_info_free_list@GOTOFF(%ebx), %edx
- movl (%edx), %eax
+ movl cse_reg_info_free_list@GOTOFF(%ebx), %eax
testl %eax, %eax
je .L239
- movl %eax, %ecx
+ movl %eax, %edx
movl 4(%eax), %eax
- movl %eax, (%edx)
+ movl %eax, cse_reg_info_free_list@GOTOFF(%ebx)
where the invariant address is pulled into both the load
and store. This is good for -216 instructions compiling
cse.c with -O2 -fpic.
Applied mainline and branch, since I'm certain that this
worked at some point in the past, and therefore must be
a regression.
r~
* cse.c (canon_hash): Reorder do_not_record test. Always
allow pic_offset_table_rtx.
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.225
diff -c -p -d -r1.225 cse.c
*** cse.c 10 May 2002 18:58:00 -0000 1.225
--- cse.c 20 May 2002 09:56:58 -0000
*************** canon_hash (x, mode)
*** 2249,2258 ****
case REG:
{
unsigned int regno = REGNO (x);
/* On some machines, we can't record any non-fixed hard register,
because extending its life will cause reload problems. We
! consider ap, fp, and sp to be fixed for this purpose.
We also consider CCmode registers to be fixed for this purpose;
failure to do so leads to failure to simplify 0<100 type of
--- 2249,2259 ----
case REG:
{
unsigned int regno = REGNO (x);
+ bool record;
/* On some machines, we can't record any non-fixed hard register,
because extending its life will cause reload problems. We
! consider ap, fp, sp, gp to be fixed for this purpose.
We also consider CCmode registers to be fixed for this purpose;
failure to do so leads to failure to simplify 0<100 type of
*************** canon_hash (x, mode)
*** 2262,2277 ****
Nor should we record any register that is in a small
class, as defined by CLASS_LIKELY_SPILLED_P. */
! if (regno < FIRST_PSEUDO_REGISTER
! && (global_regs[regno]
! || CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (regno))
! || (SMALL_REGISTER_CLASSES
! && ! fixed_regs[regno]
! && x != frame_pointer_rtx
! && x != hard_frame_pointer_rtx
! && x != arg_pointer_rtx
! && x != stack_pointer_rtx
! && GET_MODE_CLASS (GET_MODE (x)) != MODE_CC)))
{
do_not_record = 1;
return 0;
--- 2263,2290 ----
Nor should we record any register that is in a small
class, as defined by CLASS_LIKELY_SPILLED_P. */
! if (regno >= FIRST_PSEUDO_REGISTER)
! record = true;
! else if (x == frame_pointer_rtx
! || x == hard_frame_pointer_rtx
! || x == arg_pointer_rtx
! || x == stack_pointer_rtx
! || x == pic_offset_table_rtx)
! record = true;
! else if (global_regs[regno])
! record = false;
! else if (fixed_regs[regno])
! record = true;
! else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_CC)
! record = true;
! else if (SMALL_REGISTER_CLASSES)
! record = false;
! else if (CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (regno)))
! record = false;
! else
! record = true;
!
! if (!record)
{
do_not_record = 1;
return 0;