[llvm] 0ef7e00 - [Test] Add a negative unit test
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 20 22:11:37 PDT 2021
Author: Max Kazantsev
Date: 2021-04-21T12:11:05+07:00
New Revision: 0ef7e0041a392b84b9d860c4ec3cefe9da9d8473
URL: https://github.com/llvm/llvm-project/commit/0ef7e0041a392b84b9d860c4ec3cefe9da9d8473
DIFF: https://github.com/llvm/llvm-project/commit/0ef7e0041a392b84b9d860c4ec3cefe9da9d8473.diff
LOG: [Test] Add a negative unit test
Added:
Modified:
llvm/test/Transforms/GVN/PRE/pre-loop-load.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/GVN/PRE/pre-loop-load.ll b/llvm/test/Transforms/GVN/PRE/pre-loop-load.ll
index 3fb39650d8dd7..15bc49e7ab9ab 100644
--- a/llvm/test/Transforms/GVN/PRE/pre-loop-load.ll
+++ b/llvm/test/Transforms/GVN/PRE/pre-loop-load.ll
@@ -54,6 +54,56 @@ exit:
ret i32 %x
}
+; Do not PRE here because a loop-variant pointer.
+define i32 @test_load_on_cold_path_gc_variant_neg(i32 addrspace(1)* addrspace(1)* %pp) gc "statepoint-example" personality i32 ()* @"personality_function" {
+; CHECK-LABEL: @test_load_on_cold_path_gc_variant_neg(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
+; CHECK-NEXT: [[P:%.*]] = load volatile i32 addrspace(1)*, i32 addrspace(1)* addrspace(1)* [[PP:%.*]], align 8
+; CHECK-NEXT: [[X:%.*]] = load i32, i32 addrspace(1)* [[P]], align 4
+; CHECK-NEXT: [[COND:%.*]] = icmp ne i32 [[X]], 0
+; CHECK-NEXT: br i1 [[COND]], label [[HOT_PATH:%.*]], label [[COLD_PATH:%.*]]
+; CHECK: hot_path:
+; CHECK-NEXT: br label [[BACKEDGE]]
+; CHECK: cold_path:
+; CHECK-NEXT: call void @may_free_memory()
+; CHECK-NEXT: br label [[BACKEDGE]]
+; CHECK: backedge:
+; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], [[X]]
+; CHECK-NEXT: [[LOOP_COND:%.*]] = icmp ult i32 [[IV_NEXT]], 1000
+; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: ret i32 [[X]]
+;
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i32 [ 0, %entry], [%iv.next, %backedge]
+ %p = load volatile i32 addrspace(1)*, i32 addrspace(1)* addrspace(1)* %pp
+ %x = load i32, i32 addrspace(1)* %p
+ %cond = icmp ne i32 %x, 0
+ br i1 %cond, label %hot_path, label %cold_path
+
+hot_path:
+ br label %backedge
+
+cold_path:
+ call void @may_free_memory()
+ br label %backedge
+
+backedge:
+ %iv.next = add i32 %iv, %x
+ %loop.cond = icmp ult i32 %iv.next, 1000
+ br i1 %loop.cond, label %loop, label %exit
+
+exit:
+ ret i32 %x
+}
+
+
; TODO: We can PRE the load away from the hot path.
define i32 @test_load_on_cold_path(i32* %p) {
; CHECK-LABEL: @test_load_on_cold_path(
More information about the llvm-commits
mailing list