diff options
author | Florian Hahn <florian.hahn@arm.com> | 2016-11-18 13:12:07 +0000 |
---|---|---|
committer | Florian Hahn <florian.hahn@arm.com> | 2016-11-18 13:12:07 +0000 |
commit | 77382be56b3f1ff11cb7e44e6cccb0f429781e01 (patch) | |
tree | 417d59f1c8c46d3893e4a59d8a53aad4d4668f65 /llvm/test/Transforms/LoopSimplify | |
parent | 7938bd666ebbff9c5985613867dee8826ffbdb6c (diff) | |
download | bcm5719-llvm-77382be56b3f1ff11cb7e44e6cccb0f429781e01.tar.gz bcm5719-llvm-77382be56b3f1ff11cb7e44e6cccb0f429781e01.zip |
[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
llvm-svn: 287341
Diffstat (limited to 'llvm/test/Transforms/LoopSimplify')
-rw-r--r-- | llvm/test/Transforms/LoopSimplify/preserve-llvm-loop-metadata.ll | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LoopSimplify/preserve-llvm-loop-metadata.ll b/llvm/test/Transforms/LoopSimplify/preserve-llvm-loop-metadata.ll new file mode 100644 index 00000000000..bd27794d193 --- /dev/null +++ b/llvm/test/Transforms/LoopSimplify/preserve-llvm-loop-metadata.ll @@ -0,0 +1,42 @@ +; RUN: opt -loop-simplify -S < %s | FileCheck %s + +define void @test1(i32 %n) { +entry: + br label %while.cond + +while.cond: ; preds = %if.then, %if.else, %entry + %count.0 = phi i32 [ 0, %entry ], [ %add, %if.then ], [ %add2, %if.else ] + %cmp = icmp ugt i32 %count.0, %n + br i1 %cmp, label %while.end, label %while.body + +while.body: ; preds = %while.cond + %rem = and i32 %count.0, 1 + %cmp1 = icmp eq i32 %rem, 0 + br i1 %cmp1, label %if.then, label %if.else + +if.then: ; preds = %while.body + %add = add i32 %count.0, 1 + br label %while.cond, !llvm.loop !0 + +if.else: ; preds = %while.body + %add2 = add i32 %count.0, 2 + br label %while.cond, !llvm.loop !0 + +while.end: ; preds = %while.cond + ret void +} + +; CHECK: if.then +; CHECK-NOT: br {{.*}}!llvm.loop{{.*}} + +; CHECK: while.cond.backedge: +; CHECK: br label %while.cond, !llvm.loop !0 + +; CHECK: if.else +; CHECK-NOT: br {{.*}}!llvm.loop{{.*}} + + +!0 = distinct !{!0, !1} +!1 = !{!"llvm.loop.distribute.enable", i1 true} +; CHECK: !0 = distinct !{!0, !1} +; CHECK: !1 = !{!"llvm.loop.distribute.enable", i1 true} |