[PATCH] D62833: [DAGCombine][Thumb] Use single CP entry for addressing GV with large offset
Z. Zheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 17:08:53 PDT 2019
zzheng created this revision.
zzheng added reviewers: efriedma, zinob, weimingz, t.p.northover.
Herald added a subscriber: javed.absar.
Herald added a project: LLVM.
Original patch by Weiming Zhao.
When addressing a global variable with large offsets, the offset may not fit in
the load instruction and thus either needs rematerializaion or extra constant
pool entry. This casues code size bloat, especially on Thumb1.
This patch tries to encode the offset in the CP entry to save code size.
For example:
&g_big_struct.x_offset_300
Before: After:
movs r0, #75 ldr r1, .LCPI0_0
lsls r0, r0, #2 .LCPI0_0: .long g_big_struct + 300
ldr r1, .LCPI0_0
adds r0, r1
.LCPI0_0: .long g_big_struct
In best case, it saves 3 insts (and potentially reduces register pressure) as
the example shows.
In worst case, if the GV has multiple uses, the original CP entry for the GV
base is still needed, and the member can be calculated from previous addressing,
it will cost 4 extra bytes (for the CP entry).
Repository:
rL LLVM
https://reviews.llvm.org/D62833
Files:
lib/Target/ARM/ARMISelLowering.cpp
test/CodeGen/Thumb/gv-large-offset.ll
test/CodeGen/Thumb/single-gv-with-multiple-offsets.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62833.202828.patch
Type: text/x-patch
Size: 5765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190604/0ff6719f/attachment.bin>
More information about the llvm-commits
mailing list