[llvm] e36d101 - [Test] Add test with inverted branch
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 13 00:52:43 PST 2020
Author: Max Kazantsev
Date: 2020-11-13T15:51:59+07:00
New Revision: e36d101fdbb0214a37bc3cd438e7a72c9cff6983
URL: https://github.com/llvm/llvm-project/commit/e36d101fdbb0214a37bc3cd438e7a72c9cff6983
DIFF: https://github.com/llvm/llvm-project/commit/e36d101fdbb0214a37bc3cd438e7a72c9cff6983.diff
LOG: [Test] Add test with inverted branch
Added:
Modified:
llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll b/llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll
index a730f74ff511..664af7adcb44 100644
--- a/llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll
+++ b/llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll
@@ -517,6 +517,58 @@ fail:
unreachable
}
+define void @test_can_predicate_simple_unsigned_inverted(i32* %p, i32* %arr) {
+; CHECK-LABEL: @test_can_predicate_simple_unsigned_inverted(
+; CHECK-NEXT: preheader:
+; CHECK-NEXT: [[LEN:%.*]] = load i32, i32* [[P:%.*]], align 4
+; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LEN]], -1
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[LEN]], [[PREHEADER:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
+; CHECK-NEXT: [[ZERO_COND:%.*]] = icmp eq i32 [[IV]], 0
+; CHECK-NEXT: br i1 [[ZERO_COND]], label [[EXIT:%.*]], label [[RANGE_CHECK_BLOCK:%.*]]
+; CHECK: range_check_block:
+; CHECK-NEXT: [[IV_NEXT]] = sub i32 [[IV]], 1
+; CHECK-NEXT: [[RANGE_CHECK1:%.*]] = icmp ult i32 [[TMP0]], [[LEN]]
+; CHECK-NEXT: br i1 [[RANGE_CHECK1]], label [[FAIL:%.*]], label [[BACKEDGE]]
+; CHECK: backedge:
+; CHECK-NEXT: [[EL_PTR:%.*]] = getelementptr i32, i32* [[P]], i32 [[IV]]
+; CHECK-NEXT: [[EL:%.*]] = load i32, i32* [[EL_PTR]], align 4
+; CHECK-NEXT: [[LOOP_COND:%.*]] = icmp eq i32 [[EL]], 0
+; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+; CHECK: fail:
+; CHECK-NEXT: unreachable
+;
+preheader:
+ %len = load i32, i32* %p
+ br label %loop
+
+loop:
+ %iv = phi i32 [%len, %preheader], [%iv.next, %backedge]
+ %zero_cond = icmp eq i32 %iv, 0
+ br i1 %zero_cond, label %exit, label %range_check_block
+
+range_check_block:
+ %iv.next = sub i32 %iv, 1
+ %range_check = icmp uge i32 %iv.next, %len
+ br i1 %range_check, label %fail, label %backedge
+
+backedge:
+ %el.ptr = getelementptr i32, i32* %p, i32 %iv
+ %el = load i32, i32* %el.ptr
+ %loop.cond = icmp eq i32 %el, 0
+ br i1 %loop.cond, label %loop, label %exit
+
+exit:
+ ret void
+
+fail:
+ unreachable
+}
+
+
define void @test_can_predicate_simple_signed(i32* %p, i32* %arr) {
; CHECK-LABEL: @test_can_predicate_simple_signed(
; CHECK-NEXT: preheader:
More information about the llvm-commits
mailing list