[Patch]Do not simplifyLatch for loops where hoisting increments could result in extra live range interferance

yi_jiang yjiang at apple.com
Mon Oct 27 15:27:17 PDT 2014


Hi, 

This path is to address a typical code as find loop with early exit. 
        for ( ; i!=end  ; i++) {
           if (i == k)
             break; 

           ...
        }
      
        if (i == end) 
          ...
And the IR is:
 for.cond:                                         ; preds = %for.inc, %entry
   ...

for.body:                                         ; preds = %for.cond
  %0 = load i32* %coerce.val.ip9, align 4, !tbaa !1
  ...
  br i1 %cmp, label %for.end, label %for.inc    // early exit

for.inc:                                          ; preds = %for.body
  %incdec.ptr.i = getelementptr inbounds i32* %coerce.val.ip9, i64 1
  br label %for.cond

If we hoist the increment in the for.inc to the for.body then it will cause extra live range interference and hurt the performance. So this patch will check for uses of the increments operand and do not hoist if there are outside users. 

This patch will improve the spec2006 case xalanbmk(ref size) by 10% on arm64. We do not see regressions on arm64 and on x86 we see 1% regression on the case: SingleSource/Benchmarks/BenchmarkGame/fannkuch. The reasons is that if the increments in the latch was hoist, it can be combined with some other instruction which make it beneficial in this case even with live range interference.  Thank you for reviewing it. 

-Yi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141027/8699eac2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simplifylatch.patch
Type: application/octet-stream
Size: 5079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141027/8699eac2/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141027/8699eac2/attachment-0001.html>


More information about the llvm-commits mailing list