aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/StructurizeCFG
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/StructurizeCFG')
-rw-r--r--test/Transforms/StructurizeCFG/invert-compare.ll60
-rw-r--r--test/Transforms/StructurizeCFG/one-loop-multiple-backedges.ll12
-rw-r--r--test/Transforms/StructurizeCFG/post-order-traversal-bug.ll3
3 files changed, 69 insertions, 6 deletions
diff --git a/test/Transforms/StructurizeCFG/invert-compare.ll b/test/Transforms/StructurizeCFG/invert-compare.ll
new file mode 100644
index 000000000000..87d9c6d10569
--- /dev/null
+++ b/test/Transforms/StructurizeCFG/invert-compare.ll
@@ -0,0 +1,60 @@
+; RUN: opt -S -structurizecfg %s | FileCheck %s
+
+; CHECK-LABEL: @directly_invert_compare_condition_jump_into_loop(
+; CHECK: %cmp0 = fcmp uge float %arg0, %arg1
+; CHECK-NEXT: br i1 %cmp0, label %end.loop, label %Flow
+define void @directly_invert_compare_condition_jump_into_loop(i32 addrspace(1)* %out, i32 %n, float %arg0, float %arg1) #0 {
+entry:
+ br label %for.body
+
+for.body:
+ %i = phi i32 [0, %entry], [%i.inc, %end.loop]
+ %ptr = getelementptr i32, i32 addrspace(1)* %out, i32 %i
+ store i32 %i, i32 addrspace(1)* %ptr, align 4
+ %cmp0 = fcmp olt float %arg0, %arg1
+ br i1 %cmp0, label %mid.loop, label %end.loop
+
+mid.loop:
+ store i32 333, i32 addrspace(1)* %out, align 4
+ br label %for.end
+
+end.loop:
+ %i.inc = add i32 %i, 1
+ %cmp = icmp ne i32 %i.inc, %n
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
+
+; CHECK-LABEL: @invert_multi_use_compare_condition_jump_into_loop(
+; CHECK: %cmp0 = fcmp olt float %arg0, %arg1
+; CHECK: store volatile i1 %cmp0, i1 addrspace(1)* undef
+; CHECK: %0 = xor i1 %cmp0, true
+; CHECK-NEXT: br i1 %0, label %end.loop, label %Flow
+define void @invert_multi_use_compare_condition_jump_into_loop(i32 addrspace(1)* %out, i32 %n, float %arg0, float %arg1) #0 {
+entry:
+ br label %for.body
+
+for.body:
+ %i = phi i32 [0, %entry], [%i.inc, %end.loop]
+ %ptr = getelementptr i32, i32 addrspace(1)* %out, i32 %i
+ store i32 %i, i32 addrspace(1)* %ptr, align 4
+ %cmp0 = fcmp olt float %arg0, %arg1
+ store volatile i1 %cmp0, i1 addrspace(1)* undef
+ br i1 %cmp0, label %mid.loop, label %end.loop
+
+mid.loop:
+ store i32 333, i32 addrspace(1)* %out, align 4
+ br label %for.end
+
+end.loop:
+ %i.inc = add i32 %i, 1
+ %cmp = icmp ne i32 %i.inc, %n
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
+
+attributes #0 = { nounwind } \ No newline at end of file
diff --git a/test/Transforms/StructurizeCFG/one-loop-multiple-backedges.ll b/test/Transforms/StructurizeCFG/one-loop-multiple-backedges.ll
index 668a1e99d814..aff59642cbcb 100644
--- a/test/Transforms/StructurizeCFG/one-loop-multiple-backedges.ll
+++ b/test/Transforms/StructurizeCFG/one-loop-multiple-backedges.ll
@@ -11,8 +11,8 @@ bb:
bb3: ; preds = %bb7, %bb
%tmp = phi i64 [ 0, %bb ], [ %tmp8, %bb7 ]
%tmp4 = fcmp ult float %arg1, 3.500000e+00
-; CHECK: %0 = xor i1 %tmp4, true
-; CHECK: br i1 %0, label %bb5, label %Flow
+; CHECK: %tmp4 = fcmp oge float %arg1, 3.500000e+00
+; CHECK: br i1 %tmp4, label %bb5, label %Flow
br i1 %tmp4, label %bb7, label %bb5
; CHECK: bb5:
@@ -22,7 +22,8 @@ bb5: ; preds = %bb3
br i1 %tmp6, label %bb10, label %bb7
; CHECK: Flow:
-; CHECK: br i1 %3, label %bb7, label %Flow1
+; CHECK: %1 = phi i1 [ %tmp6, %bb5 ], [ %tmp4, %bb3 ]
+; CHECK-NEXT: br i1 %1, label %bb7, label %Flow1
; CHECK: bb7
bb7: ; preds = %bb5, %bb3
@@ -32,9 +33,10 @@ bb7: ; preds = %bb5, %bb3
br i1 %tmp9, label %bb3, label %bb10
; CHECK: Flow1:
-; CHECK: br i1 %7, label %bb10, label %bb3
+; CHECK: %4 = phi i1 [ %tmp9, %bb7 ], [ true, %Flow ]
+; CHECK-NEXT: br i1 %4, label %bb10, label %bb3
-; CHECK: bb10
+; CHECK: bb10:
bb10: ; preds = %bb7, %bb5
%tmp11 = phi i32 [ 15, %bb5 ], [ 255, %bb7 ]
store i32 %tmp11, i32 addrspace(1)* %arg, align 4
diff --git a/test/Transforms/StructurizeCFG/post-order-traversal-bug.ll b/test/Transforms/StructurizeCFG/post-order-traversal-bug.ll
index ba9aa2913061..a8835f19d447 100644
--- a/test/Transforms/StructurizeCFG/post-order-traversal-bug.ll
+++ b/test/Transforms/StructurizeCFG/post-order-traversal-bug.ll
@@ -59,7 +59,8 @@ for.end: ; preds = %for.body.1, %if.the
; CHECK: br i1 %{{[0-9]}}, label %for.body.1, label %Flow2
; CHECK: for.body.1:
-; CHECK: br i1 %{{[0-9]+}}, label %for.body.6, label %Flow3
+; CHECK: %cmp1.5 = icmp ne i32 %tmp22, %K1
+; CHECK-NEXT: br i1 %cmp1.5, label %for.body.6, label %Flow3
for.body.1: ; preds = %if.then, %lor.lhs.false
%best_val.233 = phi float [ %tmp5, %if.then ], [ %best_val.027, %lor.lhs.false ]
%best_count.231 = phi i32 [ %sub4, %if.then ], [ %best_count.025, %lor.lhs.false ]