[llvm] b4ac9a1 - [Test] One more IndVars test with inverted exit condition
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 13 01:03:19 PST 2020
Author: Max Kazantsev
Date: 2020-11-13T16:02:31+07:00
New Revision: b4ac9a158e028f1c2770df9bbaa184718ab410a3
URL: https://github.com/llvm/llvm-project/commit/b4ac9a158e028f1c2770df9bbaa184718ab410a3
DIFF: https://github.com/llvm/llvm-project/commit/b4ac9a158e028f1c2770df9bbaa184718ab410a3.diff
LOG: [Test] One more IndVars test with inverted exit condition
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 b0629ed79483..e963e1ddbcbe 100644
--- a/llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll
+++ b/llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll
@@ -673,4 +673,58 @@ fail:
unreachable
}
+define void @test_can_predicate_trunc_unsigned_inverted(i32* %p, i32* %arr) {
+; CHECK-LABEL: @test_can_predicate_trunc_unsigned_inverted(
+; CHECK-NEXT: preheader:
+; CHECK-NEXT: [[LEN:%.*]] = load i32, i32* [[P:%.*]], align 4
+; CHECK-NEXT: [[START:%.*]] = zext i32 [[LEN]] to i64
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[START]], [[PREHEADER:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
+; CHECK-NEXT: [[ZERO_COND:%.*]] = icmp eq i64 [[IV]], 0
+; CHECK-NEXT: br i1 [[ZERO_COND]], label [[EXIT:%.*]], label [[RANGE_CHECK_BLOCK:%.*]]
+; CHECK: range_check_block:
+; CHECK-NEXT: [[IV_NEXT]] = sub nsw i64 [[IV]], 1
+; CHECK-NEXT: [[NARROW:%.*]] = trunc i64 [[IV_NEXT]] to i32
+; CHECK-NEXT: [[RANGE_CHECK:%.*]] = icmp uge i32 [[NARROW]], [[LEN]]
+; CHECK-NEXT: br i1 [[RANGE_CHECK]], label [[FAIL:%.*]], label [[BACKEDGE]]
+; CHECK: backedge:
+; CHECK-NEXT: [[EL_PTR:%.*]] = getelementptr i32, i32* [[ARR:%.*]], i64 [[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
+ %start = zext i32 %len to i64
+ br label %loop
+
+loop:
+ %iv = phi i64 [%start, %preheader], [%iv.next, %backedge]
+ %zero_cond = icmp eq i64 %iv, 0
+ br i1 %zero_cond, label %exit, label %range_check_block
+
+range_check_block:
+ %iv.next = sub i64 %iv, 1
+ %narrow = trunc i64 %iv.next to i32
+ %range_check = icmp uge i32 %narrow, %len
+ br i1 %range_check, label %fail, label %backedge
+
+backedge:
+ %el.ptr = getelementptr i32, i32* %arr, i64 %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
+}
+
!0 = !{i32 0, i32 2147483647}
More information about the llvm-commits
mailing list