Many ARM instructions can not encode an immediate argument and in some cases it would be more efficient to hoist the loading of the integer arguments out of loops. Some ARM instructions can encode immediate arguments and it reduces register pressure to take advantage of these encoding. The range of immediate arguments is restricted and not always a simple number of low bits. The decision to hoist an integer load might usefully consider the effect on register pressure. If it causes more register pressure and spills then it might not be of any utility. The decision when to load constants may in general not be a binary one. It might be useful to load a constant over disjoin spans of a loop if it is reused. If register pressure is tight then the register might be used for other purposes and reloaded later. The x86 and x64 instruction sets can encode general integer immediate arguments for many instructions, and to some extent the ARM macro-assembler emulates these, and this might push the decision to load an integer to later in the compilation process after LICM etc and some reworking at higher level representations might be necessary.
You need to log in before you can comment on or make changes to this bug.