arm: Improve immediate generation for thumb-1 with -mpurecode [PR96769]
authorChristophe Lyon <christophe.lyon@linaro.org>
Fri, 4 Sep 2020 11:48:36 +0000 (11:48 +0000)
committerChristophe Lyon <christophe.lyon@linaro.org>
Fri, 4 Sep 2020 11:48:36 +0000 (11:48 +0000)
commit2033a63cbd0aab27d3a8450b4a4a5b371d583c85
tree2883ceb978de91b9fea34dec02518ac7a0258ce2
parentc5a6c2237a1156dc43fa32c938fc32acdfc2bff9
arm: Improve immediate generation for thumb-1 with -mpurecode [PR96769]

This patch moves the move-immediate splitter after the regular ones so
that it has lower precedence, and updates its constraints.

For
int f3 (void) { return 0x11000000; }
int f3_2 (void) { return 0x12345678; }

we now generate:
* with -O2 -mcpu=cortex-m0 -mpure-code:
f3:
movs    r0, #136
lsls    r0, r0, #21
bx      lr
f3_2:
movs    r0, #18
lsls    r0, r0, #8
adds    r0, r0, #52
lsls    r0, r0, #8
adds    r0, r0, #86
lsls    r0, r0, #8
adds    r0, r0, #121
bx      lr

* with -O2 -mcpu=cortex-m23 -mpure-code:
f3:
movs    r0, #136
lsls    r0, r0, #21
bx      lr
f3_2:
movw    r0, #22136
movt    r0, 4660
bx      lr

2020-09-04  Christophe Lyon  <christophe.lyon@linaro.org>

PR target/96769
gcc/
* config/arm/thumb1.md: Move movsi splitter for
arm_disable_literal_pool after the other movsi splitters.

gcc/testsuite/
* gcc.target/arm/pure-code/pr96769.c: New test.
gcc/config/arm/thumb1.md
gcc/testsuite/gcc.target/arm/pure-code/pr96769.c [new file with mode: 0644]