[PATCH, i386]: Remove pic_symbolic_operand predicate

Uros Bizjak ubizjak@gmail.com
Fri Jun 4 06:44:00 GMT 2010


Hello!

The sole purpose of pic_symbolic_operand is to prevent PIC operands in case of:

  /* Current assemblers are broken and do not allow @GOTOFF in
     ought but a memory context.  */

As shown in [1], even gas from binutils-2.13.1 happily assembles

addl x@GOTOFF(%ebx), %eax

in 32bit mode, as well as

addq x@GOTPCREL(%rip), %rax

in 64bit mode.

I have receive off-list confirmation from Mike Stump that:

<quote>
>> addl L_x$non_lazy_ptr-L00000000001$pb(%ecx), %eax
>>
>> Ultimately, I would like to remove checks involving
>> pic_symbolic_operands, but removing them on 64bit would be OK, too.

That appears to be fine on darwin.  I didn't spot anything that would
cause problems with it.
</quote>

Since Windows targets don't use these relocs, I visually checked that
generated results for a couple of test cases were the same.

So, the patch removes this artificial limitation.

2010-06-04  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/predicates.md (pic_symbolic_operand): Remove predicate.
	* config/i386/i386.md (*add<mode>_1): Do not use pic_symbolic_operand
	predicate in "type" attribute calculation.
	(*addsi_1_zext): Ditto.
	(*add<mode>_2): Do not use pic_symbolic_operand in insn predicate.
	(*addsi_2_zext): Ditto.
	(*add<mode>_3): Ditto.
	(*addsi_3_zext): Ditto.
	(*add<mode>_5): Ditto.

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
{,-m32}. Committed to mainline.

[1] http://gcc.gnu.org/ml/gcc/2010-06/msg00189.html

Uros.
-------------- next part --------------
Index: i386.md
===================================================================
--- i386.md	(revision 160232)
+++ i386.md	(working copy)
@@ -6118,10 +6118,6 @@
 	      (const_string "lea")
             (eq_attr "alternative" "3")
               (const_string "lea")
-	    ; Current assemblers are broken and do not allow @GOTOFF in
-	    ; ought but a memory context.
-	    (match_operand:SWI48 2 "pic_symbolic_operand" "")
-	      (const_string "lea")
 	    (match_operand:SWI48 2 "incdec_operand" "")
 	      (const_string "incdec")
 	   ]
@@ -6172,10 +6168,6 @@
   [(set (attr "type")
      (cond [(eq_attr "alternative" "1")
 	      (const_string "lea")
-	    ; Current assemblers are broken and do not allow @GOTOFF in
-	    ; ought but a memory context.
-	    (match_operand:SI 2 "pic_symbolic_operand" "")
-	      (const_string "lea")
 	    (match_operand:SI 2 "incdec_operand" "")
 	      (const_string "incdec")
 	   ]
@@ -6410,10 +6402,7 @@
    (set (match_operand:SWI48 0 "nonimmediate_operand" "=r,rm")
 	(plus:SWI48 (match_dup 1) (match_dup 2)))]
   "ix86_match_ccmode (insn, CCGOCmode)
-   && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)
-   /* Current assemblers are broken and do not allow @GOTOFF in
-      ought but a memory context.  */
-   && ! pic_symbolic_operand (operands[2], VOIDmode)"
+   && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
 {
   switch (get_attr_type (insn))
     {
@@ -6458,10 +6447,7 @@
    (set (match_operand:DI 0 "register_operand" "=r")
 	(zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
-   && ix86_binary_operator_ok (PLUS, SImode, operands)
-   /* Current assemblers are broken and do not allow @GOTOFF in
-      ought but a memory context.  */
-   && ! pic_symbolic_operand (operands[2], VOIDmode)"
+   && ix86_binary_operator_ok (PLUS, SImode, operands)"
 {
   switch (get_attr_type (insn))
     {
@@ -6576,10 +6562,7 @@
 	  (match_operand:SWI48 1 "nonimmediate_operand" "%0")))
    (clobber (match_scratch:SWI48 0 "=r"))]
   "ix86_match_ccmode (insn, CCZmode)
-   && !(MEM_P (operands[1]) && MEM_P (operands[2]))
-   /* Current assemblers are broken and do not allow @GOTOFF in
-      ought but a memory context.  */
-   && ! pic_symbolic_operand (operands[2], VOIDmode)"
+   && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
 {
   switch (get_attr_type (insn))
     {
@@ -6623,10 +6606,7 @@
    (set (match_operand:DI 0 "register_operand" "=r")
 	(zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
   "TARGET_64BIT && ix86_match_ccmode (insn, CCZmode)
-   && ix86_binary_operator_ok (PLUS, SImode, operands)
-   /* Current assemblers are broken and do not allow @GOTOFF in
-      ought but a memory context.  */
-   && ! pic_symbolic_operand (operands[2], VOIDmode)"
+   && ix86_binary_operator_ok (PLUS, SImode, operands)"
 {
   switch (get_attr_type (insn))
     {
@@ -6907,10 +6887,7 @@
 	  (const_int 0)))
    (clobber (match_scratch:SWI48 0 "=r"))]
   "ix86_match_ccmode (insn, CCGOCmode)
-   && !(MEM_P (operands[1]) && MEM_P (operands[2]))
-   /* Current assemblers are broken and do not allow @GOTOFF in
-      ought but a memory context.  */
-   && ! pic_symbolic_operand (operands[2], VOIDmode)"
+   && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
 {
   switch (get_attr_type (insn))
     {
Index: predicates.md
===================================================================
--- predicates.md	(revision 160232)
+++ predicates.md	(working copy)
@@ -420,36 +420,6 @@
     }
 })
 
-;; Return true if the operand contains a @GOT or @GOTOFF reference.
-(define_predicate "pic_symbolic_operand"
-  (match_code "const")
-{
-  op = XEXP (op, 0);
-  if (TARGET_64BIT)
-    {
-      if (GET_CODE (op) == UNSPEC
-	  && XINT (op, 1) == UNSPEC_GOTPCREL)
-	return 1;
-      if (GET_CODE (op) == PLUS
-	  && GET_CODE (XEXP (op, 0)) == UNSPEC
-	  && XINT (XEXP (op, 0), 1) == UNSPEC_GOTPCREL)
-	return 1;
-    }
-  else
-    {
-      if (GET_CODE (op) == UNSPEC)
-	return 1;
-      if (GET_CODE (op) != PLUS
-	  || !CONST_INT_P (XEXP (op, 1)))
-	return 0;
-      op = XEXP (op, 0);
-      if (GET_CODE (op) == UNSPEC
-	  && XINT (op, 1) != UNSPEC_MACHOPIC_OFFSET)
-	return 1;
-    }
-  return 0;
-})
-
 ;; Return true if OP is a symbolic operand that resolves locally.
 (define_predicate "local_symbolic_operand"
   (match_code "const,label_ref,symbol_ref")


More information about the Gcc-patches mailing list