This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

fix to Jakub's testcase


Hi
Following Jakub's testcase (already in testsuite) makes compiler
to crash after constructing refused (but correct) lea pattern.
The explanation of fix is inside patch.

(insn 16 14 18 (set (reg:SI 1 edx)
        (plus:SI (reg:SI 0 eax)
            (const (unspec[ 
                        (symbol_ref/v:SI ("x"))
                    ]  7)))) -1 (nil)
    (nil))

The patch has bootstraped only with my new lea code, but since that one has
been approved already, hope that it is enought.  Gcc from last week produces
entirely diferent crash, so the behaviour w/o that was probably somewhat
different.

/* { dg-do run { target i?86-*-* } } */
/* { dg-options "-O0 -fpic" } */

static struct {
  unsigned short a, b, c, d;
} x[10];

int foo(int i)
{
  return ((*((char *)&x[i] + i)) | (*((char *)&x[i] + i)));
}

Thu Jul 27 23:35:55 CEST 2000  Jan Hubicka  <jh@suse.cz>
	* i386.c (legitimate_address_p): Accept other bases than
	pic_offset_table_rtx for GOTOFF constructs.

*** i386.c.old	Wed Jul  5 16:48:36 2000
--- i386.c	Thu Jul 27 23:33:15 2000
*************** legitimate_address_p (mode, addr, strict
*** 2510,2523 ****
  	      goto error;
  	    }
  
! 	  /* Verify that a symbolic pic displacement includes 
! 	     the pic_offset_table_rtx register.  */
! 	  if (base != pic_offset_table_rtx
! 	      && (index != pic_offset_table_rtx || scale != 1))
! 	    {
! 	      reason = "pic displacement against invalid base";
! 	      goto error;
! 	    }
  	}
        else if (HALF_PIC_P ())
  	{
--- 2736,2762 ----
  	      goto error;
  	    }
  
!           /* This code used to verify that a symbolic pic displacement
! 	     includes the pic_offset_table_rtx register. 
! 	    
! 	     While this is good idea, unfortunately these constructs may
! 	     be created by "adds using lea" optimization for incorrect
! 	     code like:
! 
! 	     int a;
! 	     int foo(int i)
! 	       {
! 	         return *(&a+i);
! 	       }
! 
! 	     This code nonsential, but results in addressing
! 	     GOT table with pic_offset_table_rtx base.  We can't
! 	     just refuse it easilly, since it gets matched by
! 	     "addsi3" pattern, that later gets split to lea in the
! 	     case output register differs from input.  While this
! 	     can be handled by separate addsi pattern for this case
! 	     that never results in lea, this seems to be easier and
! 	     correct fix for crash to disable this test.  */
  	}
        else if (HALF_PIC_P ())
  	{

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]