self@BAYES.ARC.NASA.GOV (Matthew Self) (05/26/89)
Has anyone looked into storing small structures in registers? For example, a complex math package would be enormously improved if using a complex structure incurred no more penalty than using two separate real and imaginary part variables. This would not require having some large machine mode which the structure fits in, but actually recognizing that the components of the structure can be stored in several smaller mode registers. Clearly a lot of bookkeeping would have to be added to keep track of where the components of the structure currently are, but it could be a big win.... For example, why should foo1 and foo2 generate different code? typedef struct {double Re, Im;} complex; double foo1 (void) { complex z; z.Re = 3.0; z.Im = 4.0; return (z.Re + z.Im); } double foo2 (void) { double Re, Im; Re = 3.0; Im = 4.0; return (Re + Im); } Am I totally off the deep end, or what? It simply seems to me that structures are a nice way to reduce clutter in a program, but their use prevents any reasonable register usage, so the cost is very high. --Matthew