This is the mail archive of the gcc@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]

Inefficient code


I have a struct that looks like this:

struct Xrb
{
    uint16_t xrlen;		/* Length of I/O buffer in bytes */
    uint16_t xrbc;		/* Byte count for transfer */
    void * xrloc;		/* Pointer to I/O buffer */
    uint8_t xrci;		/* Channel number times 2 for transfer */
    uint32_t xrblk:24;	/* Random access block number */
    uint16_t xrtime;	/* Wait time for terminal input */
    uint16_t xrmod;		/* Modifiers */
};

When I write to xrblk (that 24 bit field) on my 16 bit target, I get unexpectly inefficient output:

    XRB->xrblk = 5;

	movb	#5,10(r0)
	clrb	11(r0)
	clrb	7(r0)

rather than the expected word write to the word-aligned lower half of that field.

Looking at the dumps, I see it coming into the RTL expand phase as a single write, which expand then turns into the three insns corresponding to the above.  But (of course) there is a word (HImode) move also, which has the same cost as the byte one.

Is there something I have to do in my target definition to get this to come out right?  This is a strict_alignment target, but alignment is satisfied in this example.  Also, SLOW_BYTE_ACCESS is 1.

	paul



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