[llvm] 3ea4bc7 - [IRCE] Add tests for conservative bound check

Jingu Kang via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 28 03:15:42 PDT 2021


Author: Jingu Kang
Date: 2021-04-28T11:14:21+01:00
New Revision: 3ea4bc78428f34211a9fb6843871803a2ac58183

URL: https://github.com/llvm/llvm-project/commit/3ea4bc78428f34211a9fb6843871803a2ac58183
DIFF: https://github.com/llvm/llvm-project/commit/3ea4bc78428f34211a9fb6843871803a2ac58183.diff

LOG: [IRCE] Add tests for conservative bound check

Prevent cases in which the start value of IV is bigger than bound for
increasing.

Prevent cases in which the start value of IV is smaller than bound for
decreasing.

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

Added: 
    

Modified: 
    llvm/test/Transforms/IRCE/variable-loop-bounds.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/IRCE/variable-loop-bounds.ll b/llvm/test/Transforms/IRCE/variable-loop-bounds.ll
index 5749b2c2d4119..d00d1be0f9960 100644
--- a/llvm/test/Transforms/IRCE/variable-loop-bounds.ll
+++ b/llvm/test/Transforms/IRCE/variable-loop-bounds.ll
@@ -9,6 +9,8 @@
 ; CHECK: irce: in function signed_var_imm_dec_sge: constrained Loop at depth 1 containing: %for.body<header>,%if.else,%for.inc<latch><exiting>
 ; CHECK: irce: in function signed_var_imm_dec_ne: constrained Loop at depth 1 containing: %for.body<header>,%if.else,%for.inc<latch><exiting>
 ; CHECK-NOT: irce: in function signed_var_imm_dec_eq: constrained Loop at depth 1 containing: %for.body<header>,%if.else,%for.inc<latch><exiting>
+; CHECK-NOT: irce: in function test_dec_bound_with_smaller_start_than_bound: constrained Loop at depth 1 containing: %for.body<header>,%if.else,%for.dec<latch><exiting>
+; CHECK-NOT: irce: in function test_inc_bound_with_bigger_start_than_bound: constrained Loop at depth 1 containing: %for.body<header>,%if.else,%for.dec<latch><exiting>
 
 ; CHECK-LABEL: test_inc_eq(
 ; CHECK: main.exit.selector:
@@ -352,3 +354,49 @@ for.inc:                                          ; preds = %for.body, %if.else
   %cmp = icmp eq i32 %dec, %M
   br i1 %cmp, label %for.cond.cleanup, label %for.body
 }
+
+; CHECK-LABEL: @test_dec_bound_with_smaller_start_than_bound(
+; CHECK-NOT:       preloop.exit.selector:
+define void @test_dec_bound_with_smaller_start_than_bound(i64 %0) {
+entry:
+  br label %for.body
+
+for.body:                                                ; preds = %for.dec, %entry
+  %iv = phi i64 [ %dec, %for.dec ], [ 0, %entry ]
+  %1 = icmp slt i64 %iv, %0
+  br i1 %1, label %if.else, label %for.dec
+
+if.else:                                                ; preds = %for.body
+  br label %for.dec
+
+for.dec:                                                ; preds = %if.else, %for.body
+  %dec = sub nuw nsw i64 %iv, 1
+  %2 = icmp slt i64 %dec, 1
+  br i1 %2, label %exit, label %for.body
+
+exit:                                               ; preds = %for.dec
+  ret void
+}
+
+; CHECK-LABEL: @test_inc_bound_with_bigger_start_than_bound(
+; CHECK-NOT:       main.exit.selector:
+define void @test_inc_bound_with_bigger_start_than_bound(i32 %0) {
+entry:
+  br label %for.body
+
+for.body:                                                ; preds = %for.inc, %entry
+  %iv = phi i32 [ %inc, %for.inc ], [ 200, %entry ]
+  %1 = icmp slt i32 %iv, %0
+  br i1 %1, label %if.else, label %for.inc
+
+if.else:                                                ; preds = %for.body
+  br label %for.inc
+
+for.inc:                                                ; preds = %if.else, %for.body
+  %inc = add nsw i32 %iv, 1
+  %2 = icmp sgt i32 %inc, 100
+  br i1 %2, label %exit, label %for.body
+
+exit:                                                ; preds = %for.inc
+  ret void
+}


        


More information about the llvm-commits mailing list