From 3ea4bc78428f34211a9fb6843871803a2ac58183 Mon Sep 17 00:00:00 2001 From: Jingu Kang Date: Tue, 27 Apr 2021 18:24:11 +0100 Subject: [PATCH] [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 --- llvm/test/Transforms/IRCE/variable-loop-bounds.ll | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/llvm/test/Transforms/IRCE/variable-loop-bounds.ll b/llvm/test/Transforms/IRCE/variable-loop-bounds.ll index 5749b2c..d00d1be 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
,%if.else,%for.inc ; CHECK: irce: in function signed_var_imm_dec_ne: constrained Loop at depth 1 containing: %for.body
,%if.else,%for.inc ; CHECK-NOT: irce: in function signed_var_imm_dec_eq: constrained Loop at depth 1 containing: %for.body
,%if.else,%for.inc +; CHECK-NOT: irce: in function test_dec_bound_with_smaller_start_than_bound: constrained Loop at depth 1 containing: %for.body
,%if.else,%for.dec +; CHECK-NOT: irce: in function test_inc_bound_with_bigger_start_than_bound: constrained Loop at depth 1 containing: %for.body
,%if.else,%for.dec ; 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 +} -- 2.7.4