Florian Hahn 4c11b5268c [LoopUnroll] Add support for loops with exiting headers and uncond latches.
This patch generalizes the UnrollLoop utility to support loops that exit
from the header instead of the latch. Usually, LoopRotate would take care
of must of those cases, but in some cases (e.g. -Oz), LoopRotate does
not kick in.

Codesize impact looks relatively neutral on ARM64 with -Oz + LTO.

Program                                         master     patch     diff
 External/S.../CFP2006/447.dealII/447.dealII   629060.00  627676.00  -0.2%
 External/SPEC/CINT2000/176.gcc/176.gcc        1245916.00 1244932.00 -0.1%
 MultiSourc...Prolangs-C/simulator/simulator   86100.00   86156.00    0.1%
 MultiSourc...arks/Rodinia/backprop/backprop   66212.00   66252.00    0.1%
 MultiSourc...chmarks/Prolangs-C++/life/life   67276.00   67312.00    0.1%
 MultiSourc...s/Prolangs-C/compiler/compiler   69824.00   69788.00   -0.1%
 MultiSourc...Prolangs-C/assembler/assembler   86672.00   86696.00    0.0%

Reviewers: efriedma, vsk, paquette

Reviewed By: paquette

Differential Revision: https://reviews.llvm.org/D61962

llvm-svn: 364398
2019-06-26 09:16:57 +00:00

40 lines
1.6 KiB
LLVM

; RUN: opt -S -loop-unroll -unroll-runtime -unroll-count=2 -verify-loop-info -pass-remarks=loop-unroll < %s 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Verify that runtime-unrolling a top-level loop that has nested loops does not
; make the unroller produce invalid loop-info.
; CHECK: remark: {{.*}}: unrolled loop by a factor of 2 with run-time trip count
; CHECK: @widget
; CHECK: ret void
define void @widget(double* %arg, double* %arg1, double* %p, i64* %q1, i64* %q2) local_unnamed_addr {
entry:
br label %header.outer
header.outer: ; preds = %latch.outer, %entry
%tmp = phi double* [ %tmp8, %latch.outer ], [ %arg, %entry ]
br label %header.inner
header.inner: ; preds = %latch.inner, %header.outer
%tmp5 = load i64, i64* %q1, align 8
%tmp6 = icmp eq double* %p, %arg
br i1 undef, label %exiting.inner, label %latch.outer
exiting.inner: ; preds = %latch.inner, %header.outer
br i1 undef, label %latch.inner, label %latch.outer
latch.inner: ; preds = %header.inner
store i64 %tmp5, i64* %q2, align 8
br label %header.inner
latch.outer: ; preds = %header.inner
store double 0.0, double* %p, align 8
%tmp8 = getelementptr inbounds double, double* %tmp, i64 1
%tmp9 = icmp eq double* %tmp8, %arg1
br i1 %tmp9, label %exit, label %header.outer
exit: ; preds = %latch.outer
ret void
}