[PATCH] D54170: [InstCombine][SelectionDAG][AArch64] fold gep into select to enable speculation of load
Alexandros Lamprineas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 6 11:40:41 PST 2018
labrinea created this revision.
labrinea added reviewers: spatel, john.brawn, efriedma, llvm-commits.
Herald added subscribers: kristof.beyls, javed.absar.
The motivation here is to reduce the stall cycles spent when a load is waiting for its address to become available. I am using InstCombine to fold GEP into Select when it seems profitable. This can enable speculation of loads, which is already happening in InstCombine. The DAGCombiner tries to revert the folding of load into select at the moment.
I am planning to break this patch down to smaller pieces, but first I wanted to show what I am trying to achieve and hopefully get some feedback. Another place this optimization might fit is codegenprepare. I think implementing it at the backend is not an option as it's too late to know whether we can safely speculate the loads.
The codegen test below shows the motivating example. The load doesn't have to wait for the select.
Before:
add x8, x20, #8
add x9, x20, #4
cmp w0, w19
csel x8, x8, x9, gt
ldr w0, [x8]
After:
ldp w8, w9, [x20, #4]
cmp w0, w19
csel w0, w9, w8, gt
This change improves an internal benchmark approximately by 4%.
https://reviews.llvm.org/D54170
Files:
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/Transforms/InstCombine/InstCombineCasts.cpp
lib/Transforms/InstCombine/InstCombineInternal.h
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
lib/Transforms/InstCombine/InstCombineSelect.cpp
lib/Transforms/InstCombine/InstructionCombining.cpp
test/CodeGen/AArch64/select-load.ll
test/Transforms/InstCombine/gep-select.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54170.172790.patch
Type: text/x-patch
Size: 14558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181106/cb9e48e3/attachment.bin>
More information about the llvm-commits
mailing list