[testsuite] i386 reload issue

Richard Henderson rth@cygnus.com
Mon Aug 28 18:04:00 GMT 2000


On Thu, Aug 24, 2000 at 11:18:49AM -0400, Jakub Jelinek wrote:
> 	* testsuite/g++.old-deja/g++.other/crash21.C: New test.

It turns out that defining constraints that don't match (mem const_int)
merely results in reload aborts.  "Dammit, addresses are addresses.  I
gave you a valid address; what do you want from me anyhow?"

The simplest solution I could think of involves moving the match_operand
inside the actual mem.  In this way I tell reload that I want a register
or symbolic constant or memory.  It appears to be a better solution than
we had before, since I'd never seen something of the form

	(call (mem:QI (mem:SI (plus:SI (reg:SI fp) (const_int 12)))))
i.e.
	call    *12(%ebp)

generated before.

Bootstraped with i686-linux; the test case only failed with i386, and
I checked that one by hand.



r~


        * config/i386/i386.c: Don't error on EXTRA_CONSTRAINT defined.
        (call_insn_operand): Don't expect a surrounding mem.
        (constant_call_address_operand): Likewise.
        * config/i386/i386.h (PREDICATE_CODES): Update.
        * config/i386/i386.md (call patterns): Move the match_operand
        for the call destination inside the mem.

Index: i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.174
diff -c -p -d -r1.174 i386.c
*** i386.c	2000/08/28 21:48:05	1.174
--- i386.c	2000/08/29 00:48:36
*************** Boston, MA 02111-1307, USA. */
*** 42,56 ****
  #include "basic-block.h"
  #include "ggc.h"
  
- #ifdef EXTRA_CONSTRAINT
- /* If EXTRA_CONSTRAINT is defined, then the 'S'
-    constraint in REG_CLASS_FROM_LETTER will no longer work, and various
-    asm statements that need 'S' for class SIREG will break.  */
-  error EXTRA_CONSTRAINT conflicts with S constraint letter
- /* The previous line used to be #error, but some compilers barf
-    even if the conditional was untrue.  */
- #endif
- 
  #ifndef CHECK_STACK_LIMIT
  #define CHECK_STACK_LIMIT -1
  #endif
--- 42,47 ----
*************** call_insn_operand (op, mode)
*** 1078,1087 ****
       rtx op;
       enum machine_mode mode ATTRIBUTE_UNUSED;
  {
-   if (GET_CODE (op) != MEM)
-     return 0;
-   op = XEXP (op, 0);
- 
    /* Disallow indirect through a virtual register.  This leads to
       compiler aborts when trying to eliminate them.  */
    if (GET_CODE (op) == REG
--- 1069,1074 ----
*************** constant_call_address_operand (op, mode)
*** 1114,1122 ****
       rtx op;
       enum machine_mode mode ATTRIBUTE_UNUSED;
  {
!   return (GET_CODE (op) == MEM
! 	  && CONSTANT_ADDRESS_P (XEXP (op, 0))
! 	  && GET_CODE (XEXP (op, 0)) !=  CONST_INT);
  }
  
  /* Match exactly zero and one.  */
--- 1101,1107 ----
       rtx op;
       enum machine_mode mode ATTRIBUTE_UNUSED;
  {
!   return GET_CODE (op) == SYMBOL_REF;
  }
  
  /* Match exactly zero and one.  */
Index: i386.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.h,v
retrieving revision 1.123
diff -c -p -d -r1.123 i386.h
*** i386.h	2000/08/25 16:52:24	1.123
--- i386.h	2000/08/29 00:48:37
*************** do { long l;						\
*** 2585,2592 ****
    {"aligned_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,	\
  		       LABEL_REF, SUBREG, REG, MEM}},			\
    {"pic_symbolic_operand", {CONST}},					\
!   {"call_insn_operand", {MEM}},						\
!   {"constant_call_address_operand", {MEM}},				\
    {"const0_operand", {CONST_INT, CONST_DOUBLE}},			\
    {"const1_operand", {CONST_INT}},					\
    {"const248_operand", {CONST_INT}},					\
--- 2585,2592 ----
    {"aligned_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,	\
  		       LABEL_REF, SUBREG, REG, MEM}},			\
    {"pic_symbolic_operand", {CONST}},					\
!   {"call_insn_operand", {REG, SUBREG, MEM, SYMBOL_REF}},		\
!   {"constant_call_address_operand", {SYMBOL_REF}},			\
    {"const0_operand", {CONST_INT, CONST_DOUBLE}},			\
    {"const1_operand", {CONST_INT}},					\
    {"const248_operand", {CONST_INT}},					\
Index: i386.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.md,v
retrieving revision 1.173
diff -c -p -d -r1.173 i386.md
*** i386.md	2000/08/28 21:48:05	1.173
--- i386.md	2000/08/29 00:48:37
***************
*** 8457,8468 ****
        && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF
  	  || !SYMBOL_REF_FLAG (XEXP (operands[0], 0))))
      current_function_uses_pic_offset_table = 1;
!   if (! call_insn_operand (operands[0], QImode))
      XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  }")
  
  (define_insn "*call_pop_0"
!   [(call (match_operand:QI 0 "constant_call_address_operand" "")
  	 (match_operand:SI 1 "" ""))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 3 "immediate_operand" "")))]
--- 8457,8468 ----
        && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF
  	  || !SYMBOL_REF_FLAG (XEXP (operands[0], 0))))
      current_function_uses_pic_offset_table = 1;
!   if (! call_insn_operand (XEXP (operands[0], 0), Pmode))
      XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  }")
  
  (define_insn "*call_pop_0"
!   [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" ""))
  	 (match_operand:SI 1 "" ""))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 3 "immediate_operand" "")))]
***************
*** 8477,8497 ****
    [(set_attr "type" "call")])
    
  (define_insn "*call_pop_1"
!   [(call (match_operand:QI 0 "call_insn_operand" "m")
  	 (match_operand:SI 1 "" ""))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 3 "immediate_operand" "i")))]
    ""
    "*
  {
!   if (constant_call_address_operand (operands[0], QImode))
      {
        if (SIBLING_CALL_P (insn))
  	return \"jmp\\t%P0\";
        else
  	return \"call\\t%P0\";
      }
-   operands[0] = XEXP (operands[0], 0);
    if (SIBLING_CALL_P (insn))
      return \"jmp\\t%*%0\";
    else
--- 8477,8496 ----
    [(set_attr "type" "call")])
    
  (define_insn "*call_pop_1"
!   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
  	 (match_operand:SI 1 "" ""))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 3 "immediate_operand" "i")))]
    ""
    "*
  {
!   if (constant_call_address_operand (operands[0], Pmode))
      {
        if (SIBLING_CALL_P (insn))
  	return \"jmp\\t%P0\";
        else
  	return \"call\\t%P0\";
      }
    if (SIBLING_CALL_P (insn))
      return \"jmp\\t%*%0\";
    else
***************
*** 8513,8524 ****
        && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF
  	  || !SYMBOL_REF_FLAG (XEXP (operands[0], 0))))
      current_function_uses_pic_offset_table = 1;
!   if (! call_insn_operand (operands[0], QImode))
      XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  }")
  
  (define_insn "*call_0"
!   [(call (match_operand:QI 0 "constant_call_address_operand" "")
  	 (match_operand:SI 1 "" ""))]
    ""
    "*
--- 8512,8523 ----
        && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF
  	  || !SYMBOL_REF_FLAG (XEXP (operands[0], 0))))
      current_function_uses_pic_offset_table = 1;
!   if (! call_insn_operand (XEXP (operands[0], 0), Pmode))
      XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  }")
  
  (define_insn "*call_0"
!   [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" ""))
  	 (match_operand:SI 1 "" ""))]
    ""
    "*
***************
*** 8531,8537 ****
    [(set_attr "type" "call")])
  
  (define_insn "*call_1"
!   [(call (match_operand:QI 0 "call_insn_operand" "m")
  	 (match_operand:SI 1 "" ""))]
    ""
    "*
--- 8530,8536 ----
    [(set_attr "type" "call")])
  
  (define_insn "*call_1"
!   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
  	 (match_operand:SI 1 "" ""))]
    ""
    "*
***************
*** 8543,8549 ****
        else
  	return \"call\\t%P0\";
      }
-   operands[0] = XEXP (operands[0], 0);
    if (SIBLING_CALL_P (insn))
      return \"jmp\\t%*%0\";
    else
--- 8542,8547 ----
***************
*** 8576,8582 ****
        && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF
  	  || !SYMBOL_REF_FLAG (XEXP (operands[1], 0))))
      current_function_uses_pic_offset_table = 1;
!   if (! call_insn_operand (operands[1], QImode))
      XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
  }")
  
--- 8574,8580 ----
        && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF
  	  || !SYMBOL_REF_FLAG (XEXP (operands[1], 0))))
      current_function_uses_pic_offset_table = 1;
!   if (! call_insn_operand (XEXP (operands[1], 0), Pmode))
      XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
  }")
  
***************
*** 8595,8601 ****
        && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF
  	  || !SYMBOL_REF_FLAG (XEXP (operands[1], 0))))
      current_function_uses_pic_offset_table = 1;
!   if (! call_insn_operand (operands[1], QImode))
      XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
  }")
  
--- 8593,8599 ----
        && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF
  	  || !SYMBOL_REF_FLAG (XEXP (operands[1], 0))))
      current_function_uses_pic_offset_table = 1;
!   if (! call_insn_operand (XEXP (operands[1], 0), Pmode))
      XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
  }")
  
***************
*** 11056,11062 ****
  
  (define_insn "*call_value_pop_0"
    [(set (match_operand 0 "" "")
! 	(call (match_operand:QI 1 "constant_call_address_operand" "")
  	      (match_operand:SI 2 "" "")))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 4 "immediate_operand" "")))]
--- 11054,11060 ----
  
  (define_insn "*call_value_pop_0"
    [(set (match_operand 0 "" "")
! 	(call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
  	      (match_operand:SI 2 "" "")))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 4 "immediate_operand" "")))]
***************
*** 11072,11078 ****
  
  (define_insn "*call_value_pop_1"
    [(set (match_operand 0 "" "")
! 	(call (match_operand:QI 1 "call_insn_operand" "m")
  	      (match_operand:SI 2 "" "")))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 4 "immediate_operand" "i")))]
--- 11070,11076 ----
  
  (define_insn "*call_value_pop_1"
    [(set (match_operand 0 "" "")
! 	(call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
  	      (match_operand:SI 2 "" "")))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 4 "immediate_operand" "i")))]
***************
*** 11086,11092 ****
        else
  	return \"call\\t%P1\";
      }
-   operands[1] = XEXP (operands[1], 0);
    if (SIBLING_CALL_P (insn))
      return \"jmp\\t%*%1\";
    else
--- 11084,11089 ----
***************
*** 11096,11102 ****
  
  (define_insn "*call_value_0"
    [(set (match_operand 0 "" "")
! 	(call (match_operand:QI 1 "constant_call_address_operand" "")
  	      (match_operand:SI 2 "" "")))]
    ""
    "*
--- 11093,11099 ----
  
  (define_insn "*call_value_0"
    [(set (match_operand 0 "" "")
! 	(call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
  	      (match_operand:SI 2 "" "")))]
    ""
    "*
***************
*** 11110,11116 ****
  
  (define_insn "*call_value_1"
    [(set (match_operand 0 "" "")
! 	(call (match_operand:QI 1 "call_insn_operand" "m")
  	      (match_operand:SI 2 "" "")))]
    ""
    "*
--- 11107,11113 ----
  
  (define_insn "*call_value_1"
    [(set (match_operand 0 "" "")
! 	(call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
  	      (match_operand:SI 2 "" "")))]
    ""
    "*
***************
*** 11122,11128 ****
        else
  	return \"call\\t%P1\";
      }
-   operands[1] = XEXP (operands[1], 0);
    if (SIBLING_CALL_P (insn))
      return \"jmp\\t%*%1\";
    else
--- 11119,11124 ----


More information about the Gcc-patches mailing list