[llvm] r339159 - [LICM] Strengthen assume hoisting tests [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 7 10:54:36 PDT 2018
Author: reames
Date: Tue Aug 7 10:54:36 2018
New Revision: 339159
URL: http://llvm.org/viewvc/llvm-project?rev=339159&view=rev
Log:
[LICM] Strengthen assume hoisting tests [NFC]
As requested in review of https://reviews.llvm.org/D50364
Modified:
llvm/trunk/test/Transforms/LICM/assume.ll
Modified: llvm/trunk/test/Transforms/LICM/assume.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LICM/assume.ll?rev=339159&r1=339158&r2=339159&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LICM/assume.ll (original)
+++ llvm/trunk/test/Transforms/LICM/assume.ll Tue Aug 7 10:54:36 2018
@@ -51,4 +51,49 @@ loop:
br label %loop
}
+; Can't hoist because the call may throw and the assume
+; may never execute.
+define void @f_2(i1 %cond, i32* %ptr) {
+; CHECK-LABEL: @f_2(
+; CHECK-LABEL: entry:
+; CHECK-LABEL: loop:
+; CHECK: call void @llvm.assume(i1 %cond)
+; CHECK: %val = load i32, i32* %ptr
+
+entry:
+ br label %loop
+
+loop:
+ %x = phi i32 [ 0, %entry ], [ %x.inc, %loop ]
+ call void @maythrow()
+ call void @llvm.assume(i1 %cond)
+ %val = load i32, i32* %ptr
+ %x.inc = add i32 %x, %val
+ br label %loop
+}
+
+; Note: resulting loop could be peeled and then hoisted, but
+; by default assume is captured in phi cycle.
+define void @f_3(i1 %cond, i32* %ptr) {
+; CHECK-LABEL: @f_3(
+; CHECK-LABEL: entry:
+; CHECK: %val = load i32, i32* %ptr
+; CHECK-LABEL: loop:
+; CHECK: call void @llvm.assume(i1 %x.cmp)
+
+entry:
+ br label %loop
+
+loop:
+ %x = phi i32 [ 0, %entry ], [ %x.inc, %loop ]
+ %x.cmp = phi i1 [%cond, %entry], [%cond.next, %loop]
+ call void @llvm.assume(i1 %x.cmp)
+ %val = load i32, i32* %ptr
+ %cond.next = icmp eq i32 %val, 5
+ %x.inc = add i32 %x, %val
+ br label %loop
+}
+
+
+declare void @maythrow()
declare void @llvm.assume(i1)
More information about the llvm-commits
mailing list