llvm/test/Transforms/SimplifyCFG/preserve-llvm-loop-metadata.ll
Florian Hahn 8a56643640 [simplifycfg][loop-simplify] Preserve loop metadata in 2 transformations.
insertUniqueBackedgeBlock in lib/Transforms/Utils/LoopSimplify.cpp now
propagates existing llvm.loop metadata to newly the added backedge.

llvm::TryToSimplifyUncondBranchFromEmptyBlock in lib/Transforms/Utils/Local.cpp
now propagates existing llvm.loop metadata to the branch instructions in the
predecessor blocks of the empty block that is removed.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287341 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-18 13:12:07 +00:00

54 lines
1.6 KiB
LLVM

; RUN: opt -simplifycfg -S < %s | FileCheck %s
define void @test1(i32 %n) #0 {
entry:
%n.addr = alloca i32, align 4
%count = alloca i32, align 4
store i32 %n, i32* %n.addr, align 4
%0 = bitcast i32* %count to i8*
store i32 0, i32* %count, align 4
br label %while.cond
while.cond: ; preds = %if.end, %entry
%1 = load i32, i32* %count, align 4
%2 = load i32, i32* %n.addr, align 4
%cmp = icmp ule i32 %1, %2
br i1 %cmp, label %while.body, label %while.end
while.body: ; preds = %while.cond
%3 = load i32, i32* %count, align 4
%rem = urem i32 %3, 2
%cmp1 = icmp eq i32 %rem, 0
br i1 %cmp1, label %if.then, label %if.else
if.then: ; preds = %while.body
%4 = load i32, i32* %count, align 4
%add = add i32 %4, 1
store i32 %add, i32* %count, align 4
br label %if.end
; CHECK: if.then:
; CHECK: br label %while.cond, !llvm.loop !0
if.else: ; preds = %while.body
%5 = load i32, i32* %count, align 4
%add2 = add i32 %5, 2
store i32 %add2, i32* %count, align 4
br label %if.end
; CHECK: if.else:
; CHECK: br label %while.cond, !llvm.loop !0
if.end: ; preds = %if.else, %if.then
br label %while.cond, !llvm.loop !0
while.end: ; preds = %while.cond
%6 = bitcast i32* %count to i8*
ret void
}
!0 = distinct !{!0, !1}
!1 = !{!"llvm.loop.distribute.enable", i1 true}
; CHECK: !0 = distinct !{!0, !1}
; CHECK: !1 = !{!"llvm.loop.distribute.enable", i1 true}