<div dir="ltr"><div><span style="font-size:12.8000001907349px">Hello</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">I am not sure I understand the logic for merging GEPs in </span>InstructionCombining.cpp:</div><span style="font-size:12.8000001907349px"><div><span style="font-size:12.8000001907349px"><br></span></div>static bool </span><span class="" style="font-size:12.8000001907349px">shouldMergeGEPs</span><span style="font-size:12.8000001907349px">(GEPOperator &GEP, GEPOperator &Src) {</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  // If this GEP has only 0 indices, it is the same pointer as</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  // Src. If Src is not a trivial GEP too, don't combine</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  // the indices.</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  if (GEP.hasAllZeroIndices() && !Src.hasAllZeroIndices() &&</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">      !Src.hasOneUse())</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">    return false;</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  return true;</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">}</span><br><div><br></div><div>I have a case where </div><div>GEP: %arrayidx7 = getelementptr inbounds i32* %arrayidx, i32 %shl6</div><div>Src: %arrayidx = getelementptr inbounds [4096 x i32]* @phasor_4096, i32 0, i32 %shl2</div><div><br></div><div>GEP.<span style="font-size:12.8000001907349px">hasAllZeroIndices() will return false and the merge will occur</span></div><div>Why do we want to combine these 2 getelementptr?</div><div><br></div><div>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)</div><div><br></div><div>Thanks.</div>







</div>