I'm running CodeWarrior 184.108.40.2060 with a ColdFire 5271.
I've been trying to review and optimize our application, running on a MCF5270. I'm finding when we dereference a pointer to a structure, or equate structures, the compiler generates code larger and slower than we would like.
*(InternalPVPoint*)ptr1 = *(InternalPVPoint*)ptr2;
The compiler obviously knows the structure is 4 bytes, and the processor is a 32-bit ColdFire..
SO: why did CodeWarrior not generate a single longword move? How can I affect the compiler output to do this?
this example is perhaps a bit overly complicated as the type InternalPVPoint is a union containing bitfields:
typdef union tagInternalPVPoint
uint_32 TYPE : 10;
uint_32 INSTANCE : 22;
However, using even simple structures:
typedef struct tagMyStruct
typedef struct tagOtherStruct
*first = *((MyStruct*)second);
Why just do word moves?
But maybe this example is too artificial. Anyways, can anyone explain the compilers behaviour here, and how to write optimal code in these situations?
Where is the trade-off for calling an optimized (inline?) memcpy function?
Alban Edit: CW version number and core in subject line.
Message Edited by Alban on 2007-03-27 11:36 PM