[llvm] 8a04cdb - [Test] Add signed version of a test
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 21:30:48 PDT 2020
Author: Max Kazantsev
Date: 2020-09-16T11:30:21+07:00
New Revision: 8a04cdb510c89b8c6419d6ce1e98967d7ac9abb2
URL: https://github.com/llvm/llvm-project/commit/8a04cdb510c89b8c6419d6ce1e98967d7ac9abb2
DIFF: https://github.com/llvm/llvm-project/commit/8a04cdb510c89b8c6419d6ce1e98967d7ac9abb2.diff
LOG: [Test] Add signed version of a test
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 7956735922fe..62a0a1dcf865 100644
--- a/llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll
+++ b/llvm/test/Transforms/IndVarSimplify/predicated_ranges.ll
@@ -10,8 +10,8 @@
; 1 <= iv <= len [3];
; 4. iv.next = iv - 1 and [3], therefore
; 0 <= iv.next < len.
-define void @test_predicated_simple(i32* %p, i32* %arr) {
-; CHECK-LABEL: @test_predicated_simple(
+define void @test_predicated_simple_unsigned(i32* %p, i32* %arr) {
+; CHECK-LABEL: @test_predicated_simple_unsigned(
; CHECK-NEXT: preheader:
; CHECK-NEXT: [[LEN:%.*]] = load i32, i32* [[P:%.*]], align 4, [[RNG0:!range !.*]]
; CHECK-NEXT: br label [[LOOP:%.*]]
@@ -60,4 +60,54 @@ fail:
unreachable
}
+define void @test_predicated_simple_signed(i32* %p, i32* %arr) {
+; CHECK-LABEL: @test_predicated_simple_signed(
+; CHECK-NEXT: preheader:
+; CHECK-NEXT: [[LEN:%.*]] = load i32, i32* [[P:%.*]], align 4, [[RNG0]]
+; 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_CHECK:%.*]] = icmp slt i32 [[IV_NEXT]], [[LEN]]
+; CHECK-NEXT: br i1 [[RANGE_CHECK]], label [[BACKEDGE]], label [[FAIL:%.*]]
+; 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, !range !0
+ 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 slt i32 %iv.next, %len
+ br i1 %range_check, label %backedge, label %fail
+
+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
+}
+
!0 = !{i32 0, i32 2147483647}
More information about the llvm-commits
mailing list