<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>        for ( ; i!=end  ; i++) {</div><div>           if (i == k)</div><div>             break; </div><div><br></div><div>           ...</div><div>        }</div><div>      </div><div>        if (i == end) </div><div>          ...</div><div>And the IR is:</div><div> <span style="font-family: Menlo; font-size: 11px;">for.cond: </span><span style="font-family: Menlo; font-size: 11px;">                                        </span><span style="font-family: Menlo; font-size: 11px;">; preds = %for.inc, %entry</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">   ...</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">for.body:                                         ; preds = %for.cond</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  %0 = load i32* %coerce.val.ip9, align 4, !tbaa !1</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  ...</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  br i1 %cmp, label %for.end, label %for.inc    // early exit</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">for.inc:                                          ; preds = %for.body</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  %incdec.ptr.i = getelementptr inbounds i32* %coerce.val.ip9, i64 1</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  br label %for.cond</div><div><br></div><div>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. </div><div><br></div><div>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. </div><div><br></div><div>-Yi</div></body></html>