Generated insns far from being optimal

Peter Barada pbarada@mail.wm.sps.mot.com
Wed Mar 20 08:46:00 GMT 2002


>It puts the adress of i into a pseudo-register, and then move the value
>5 into the address pointed by this register. While it is correct, it'd
>be much more interesting to directly have something like this (taken
>from the i386 target generation):
>
>(insn 9 3 12 (set (mem/f:SI (symbol_ref:SI ("i")) 0)
>        (const_int 5 [0x5])) -1 (nil)
>    (nil))

Look at your GO_IF_LEGITIMATE_ADDRESS().  It's defined as:

#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
{									\
    if (GET_CODE(X) == REG && REG_OK_FOR_BASE_P(X))                     \
      goto LABEL;							\
}

This indicates that the only legitimate addressing mode is register
indirect since if X was:

(mem/f:SI (symbol_ref:SI ("i")) 0)

control falls out of the bottom of the macro and the address is
treated as illegal.

I think you want to modify it to be something like(lifted from m68k.h):

/* Recognize any constant value that is a valid address.  */
#define CONSTANT_ADDRESS_P(X)   \
  (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF		\
   || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST		\
   || GET_CODE (X) == HIGH)

/* Allow any constant address *and* register indirect */
#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
{									\
    if (CONSTANT_ADDRESS_P(X))						\
      goto LABEL;							\
    if (GET_CODE(X) == REG && REG_OK_FOR_BASE_P(X))                     \
      goto LABEL;							\
}

-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)



More information about the Gcc mailing list