This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Remove some more unused code from ia64 back end.
James E Wilson <wilson@specifixinc.com> writes:
> On Thu, 2004-07-29 at 11:30, Zack Weinberg wrote:
>> 1) setjmp_operand is unused and appears never to have been used.
>
> You apparently did not look very hard. The use of it disappeared in
> between gcc-3.2 and gcc-3.3.
Then the change that got rid of the need for it does not mention this
in the ChangeLog. I'm not sure how else I should have looked.
>> 2) There is a block of code in got_symbolic_operand which is
>> unreachable, and has been so since July 2000. I conclude it's not
>> necessary. It can be pulled back out of CVS if we do want it.
>
> This is an optimization issue, not a correctness issue. We get better
> code if we have the extra tests, but we get correct code whether or not
> it is there. Please put the code back with the spurious "return 1;"
> removed.
I would prefer not to put it back exactly as it was, since it makes
use of the currently_expanding_to_rtl hack. Given the way it is used,
i.e. exclusively in *load_symptr_high and *load_symptr_low, which
appear only to be generated as a consequence of calling
ia64_expand_load_address, I believe that test to be unnecessary.
Also, it appears that the spurious 'return 1;' was dislocated from the
case SYMBOL_REF: below, so that case is incorrectly failing always.
I'll test the appended patch on ia64-hpux. Could you give an example
of the sort of code that should be optimized better with the extra
tests in place, so that I can make sure it works?
zw
* config/ia64/ia64.c (got_symbolic_operand): Partially revert
removal of unreachable extra tests in the CONST case. Make
them reachable again. Do not check currently_expanding_to_rtl.
Correct the return value in the SYMBOL_REF case. Clarify comments.
===================================================================
Index: config/ia64/ia64.c
--- config/ia64/ia64.c 29 Jul 2004 18:30:25 -0000 1.313
+++ config/ia64/ia64.c 29 Jul 2004 21:45:34 -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;