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]
Other format: [Raw text]

Re: Remove some more unused code from ia64 back end.


James E Wilson <wilson@specifixinc.com> writes:

> On Thu, 2004-07-29 at 17:54, Zack Weinberg wrote:
>> ... which is what the patch appended to the message you're responding
>> to did.  Are you happy with that patch?
>
> Yes, sorry I didn't make that clear.

I bootstrapped that patch successfully, and then I wrote a test
program to verify that the GOT-entry coalescing worked.  (Data space
object, bunch of functions returning pointers to different offsets
from the start of that object.)  And I got an ICE due to the pickier
operand predicate rejecting (plus (symbol_ref "object") (const_int 8192)).

This turns out to be a bug in ia64_expand_load_address: the condition
it uses for splitting up a load-from-GOT is inconsistent with the
check condition in got_symbolic_operand.  The former splits a load if
its offset is nonzero mod 0x1fff; the latter rejects a highpart load if
its offset is nonzero mod 0x3fff.  got_symbolic_operand is correct;
[-8192,8191] is the range of an add instruction with 14-bit immediate.

So here is the patch I propose to check in.  Not doing it now, though;
too tired.  A note on the test case: it will get a spurious failure on
any ia64 subtarget for which -mauto-pic is the default.  This could be
prevented by adding -mno-auto-pic to the dg-options line, but that
option is not recognized.  Shall I add it?

zw

        * config/ia64/ia64.c (got_symbolic_operand): Do require a
        symbol+offset operand to have its offset be zero mod 0x3fff
        when GOT entries are in use.  Clarify logic in SYMBOL_REF
        case.  Clarify comments.
        (ia64_expand_load_address): Split a symbol+offset load when
        the offset is nonzero mod 0x3fff, not 0x1fff.

        * gcc.dg/ia64-got-1.c: New test case.

===================================================================
Index: config/ia64/ia64.c
--- config/ia64/ia64.c	29 Jul 2004 18:30:25 -0000	1.313
+++ config/ia64/ia64.c	30 Jul 2004 07:52:54 -0000
@@ -471,6 +471,7 @@ got_symbolic_operand (rtx op, enum machi
   switch (GET_CODE (op))
     {
     case CONST:
+      /* Accept only (plus (symbol_ref) (const_int)).  */
       op = XEXP (op, 0);
       if (GET_CODE (op) != PLUS)
 	return 0;
@@ -479,11 +480,20 @@ got_symbolic_operand (rtx op, enum machi
       op = XEXP (op, 1);
       if (GET_CODE (op) != CONST_INT)
 	return 0;
+
+     /* Ok if we're not using GOT entries at all.  */
+     if (TARGET_NO_PIC || TARGET_AUTO_PIC)
       return 1;
+      
+     /* The low 14 bits of the constant have been forced to zero
+	by ia64_expand_load_address, so that we do not use up so
+	many GOT entries.  Prevent cse from undoing this.  */
+     return (INTVAL (op) & 0x3fff) == 0;
 
     case SYMBOL_REF:
-      if (SYMBOL_REF_SMALL_ADDR_P (op))
-	return 0;
+      /* This sort of load should not be used for things in sdata.  */
+      return !SYMBOL_REF_SMALL_ADDR_P (op);
+
     case LABEL_REF:
       return 1;
 
@@ -1125,7 +1135,7 @@ ia64_expand_load_address (rtx dest, rtx 
   if (GET_CODE (src) == CONST
       && GET_CODE (XEXP (src, 0)) == PLUS
       && GET_CODE (XEXP (XEXP (src, 0), 1)) == CONST_INT
-      && (INTVAL (XEXP (XEXP (src, 0), 1)) & 0x1fff) != 0)
+      && (INTVAL (XEXP (XEXP (src, 0), 1)) & 0x3fff) != 0)
     {
       rtx sym = XEXP (XEXP (src, 0), 0);
       HOST_WIDE_INT ofs, hi, lo;
===================================================================
Index: testsuite/gcc.dg/ia64-got-1.c
--- testsuite/gcc.dg/ia64-got-1.c	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/ia64-got-1.c	30 Jul 2004 07:52:57 -0000
@@ -0,0 +1,23 @@
+/* { dg-do compile { target ia64*-*-* } } */
+/* { dg-options "-O2 -fPIC" } */
+
+/* { dg-final { scan-assembler "@ltoffx\\(object#\\)" } } */
+/* { dg-final { scan-assembler "@ltoffx\\(object#\[-+\]16384\\)" } } */
+/* { dg-final { scan-assembler-not "@ltoffx\\(object#\[-+\]1\\)" } } */
+/* { dg-final { scan-assembler-not "@ltoffx\\(object#\[-+\]8191\\)" } } */
+/* { dg-final { scan-assembler-not "@ltoffx\\(object#\[-+\]8192\\)" } } */
+/* { dg-final { scan-assembler-not "@ltoffx\\(object#\[-+\]8193\\)" } } */
+/* { dg-final { scan-assembler-not "@ltoffx\\(object#\[-+\]16383\\)" } } */
+/* { dg-final { scan-assembler-not "@ltoffx\\(object#\[-+\]16385\\)" } } */
+
+/* must not be in sdata */
+extern char object[];
+
+#define r(n) char *r_##n (void) { return &object[n]; }
+#define R(n) char *R_##n (void) { return &object[-n]; }
+
+#define t(n) r(n) R(n)
+
+t(0) t(1)
+t(8191) t(8192) t(8193)
+t(16383) t(16384) t(16385)


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