Currently the load/store optimizer will only fold in increments of the same size as the load/store. This patch expands that to any legal immediate for the post-inc instruction.
Details
Diff Detail
Event Timeline
This causes miscompiles for me (code that gives the wrong result at runtime). I've still to narrow it down to something that can be inspected though...
OK thanks. I was hoping/expecting any problems to come up at compile-time.
Which target are you compiling for? That might at least narrow down what type of instruction it is.
I'm building for armv7-w64-mingw32 (i.e. armv7-windows-gnu), which is implicitly thumb(2).
Ok, I think I've got it reduced fairly well. Use https://martin.st/temp/vp8-bitstream.c as souce.
Compiled with clang -target armv7-w64-mingw32 vp8-bitstream.c -S -o bad.s -O2, I'm getting this diff:
$ diff -u good.s bad.s @@ -3831,8 +3832,7 @@ pop.w {r4, r5, r6, r7, r8, r9, r10, r11, pc} .LBB6_246: @ %if.else332 add.w r0, r9, #110592 - add.w r0, r0, #1584 - ldrd r1, r2, [r0] + ldrd r1, r2, [r0, #1584]! mov r0, r6 bl vp8_pack_tokens .LBB6_247: @ %if.end335
If I try to assemble bad.s, I'm getting this error:
bad.s:3835:15: error: invalid operand for instruction ldrd r1, r2, [r0, #1584]! ^
If compiling directly to an object file, no error is produced.
Thanks. That certainly sounds out of range! I'll take a look and try to add some extra testing.