Comment 2 for bug 1646883

Revision history for this message
David Brown (davidbrown) wrote :

gcc 8 gives the same results (baring very minor differences).

Testing without the "-mcpu=cortex-m4 -mthumb" gives an interesting view, however, which may give some insight into the problem.

The code produced for test1 and test2 is similar in this case, with one major difference. The test2 code uses a single base address and accesses the rest of the data at offsets 0 to 28 (just like on the M4). For test1, however, the base used is 2047 higher - and so the offsets in the code are from -2047 to -2019. This makes sense on 32-bit ARM instructions - offsets here are allowed in the range -4095 to +4095. However, with Thumb-2, the offsets must be in the range -255 to +4095 (or -255 to +255 for some instructions).

Perhaps with -O2, the compiler is trying to use the same base as for 32-bit ARM, realising the offsets are out of range, and generating multiple bases instead?