[LLVMdev] Question about shouldMergeGEPs in InstructionCombining
Francois Pichet
pichet2000 at gmail.com
Sun Feb 22 15:34:11 PST 2015
Hello
I am not sure I understand the logic for merging GEPs in
InstructionCombining.cpp:
static bool shouldMergeGEPs(GEPOperator &GEP, GEPOperator &Src) {
// If this GEP has only 0 indices, it is the same pointer as
// Src. If Src is not a trivial GEP too, don't combine
// the indices.
if (GEP.hasAllZeroIndices() && !Src.hasAllZeroIndices() &&
!Src.hasOneUse())
return false;
return true;
}
I have a case where
GEP: %arrayidx7 = getelementptr inbounds i32* %arrayidx, i32 %shl6
Src: %arrayidx = getelementptr inbounds [4096 x i32]* @phasor_4096, i32 0,
i32 %shl2
GEP.hasAllZeroIndices() will return false and the merge will occur
Why do we want to combine these 2 getelementptr?
On my out of tree target, combining these 2 GetElementPtr create a
performance regression because since GEP is in a loop (Src is out of loop),
GEP will lower to a more complicated address for a subsequent load. (the
complicated address needs to be calculated over and over in the loop)
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150222/010b0393/attachment.html>
More information about the llvm-dev
mailing list