[llvm] d57ed84 - [CGP] Add test to show the missed case in remove llvm.assume
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 7 03:21:17 PDT 2023
Author: Serguei Katkov
Date: 2023-06-07T17:20:57+07:00
New Revision: d57ed844feb7036a21e849c8dcda269a451ad5c3
URL: https://github.com/llvm/llvm-project/commit/d57ed844feb7036a21e849c8dcda269a451ad5c3
DIFF: https://github.com/llvm/llvm-project/commit/d57ed844feb7036a21e849c8dcda269a451ad5c3.diff
LOG: [CGP] Add test to show the missed case in remove llvm.assume
Added:
Modified:
llvm/test/Transforms/CodeGenPrepare/X86/delete-assume-dead-code.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/delete-assume-dead-code.ll b/llvm/test/Transforms/CodeGenPrepare/X86/delete-assume-dead-code.ll
index a10933427ed8f..b7c9c0c3d2867 100644
--- a/llvm/test/Transforms/CodeGenPrepare/X86/delete-assume-dead-code.ll
+++ b/llvm/test/Transforms/CodeGenPrepare/X86/delete-assume-dead-code.ll
@@ -26,5 +26,67 @@ exit:
ret i32 %conv
}
+define i32 @test2(i32 %N) nounwind {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[HEADER:%.*]]
+; CHECK: header:
+; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_INC:%.*]], [[HEADER]] ]
+; CHECK-NEXT: [[IV2:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[IV2_INC:%.*]], [[HEADER]] ]
+; CHECK-NEXT: [[IV_INC]] = add i32 [[IV]], 1
+; CHECK-NEXT: [[IV2_INC]] = add i32 [[IV2]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[IV]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[EXIT:%.*]], label [[HEADER]]
+; CHECK: exit:
+; CHECK-NEXT: ret i32 [[IV]]
+;
+entry:
+ br label %header
+
+header:
+ %iv = phi i32 [0, %entry], [%iv.inc, %header]
+ %iv2 = phi i32 [0, %entry], [%iv2.inc, %header]
+ %iv.inc = add i32 %iv, 1
+ %iv2.inc = add i32 %iv2, 1
+ %cmp = icmp eq i32 %iv, %N
+ %cmp2 = icmp slt i32 %iv2, %N
+ call void @llvm.assume(i1 %cmp2)
+ br i1 %cmp, label %exit, label %header
+
+exit:
+ ret i32 %iv
+}
+
+define i32 @test3(i32 %N) nounwind {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[HEADER:%.*]]
+; CHECK: header:
+; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_INC:%.*]], [[HEADER]] ]
+; CHECK-NEXT: [[IV2:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[IV2_INC:%.*]], [[HEADER]] ]
+; CHECK-NEXT: [[IV_INC]] = add i32 [[IV]], 1
+; CHECK-NEXT: [[IV2_INC]] = add i32 [[IV2]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[IV]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[EXIT:%.*]], label [[HEADER]]
+; CHECK: exit:
+; CHECK-NEXT: ret i32 [[IV]]
+;
+entry:
+ br label %header
+
+header:
+ %iv = phi i32 [0, %entry], [%iv.inc, %header]
+ %iv2 = phi i32 [0, %entry], [%iv2.inc, %header]
+ %iv.inc = add i32 %iv, 1
+ %iv2.inc = add i32 %iv2, 1
+ %cmp = icmp eq i32 %iv, %N
+ %cmp2 = icmp slt i32 %iv2.inc, %N
+ call void @llvm.assume(i1 %cmp2)
+ br i1 %cmp, label %exit, label %header
+
+exit:
+ ret i32 %iv
+}
+
declare i64 @foo(ptr) nounwind readonly willreturn
declare void @llvm.assume(i1 noundef) nounwind willreturn
More information about the llvm-commits
mailing list