[llvm] d119c38 - [CGP] Additional tests for removing operand of assume. NFC.
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 22:08:01 PDT 2023
Author: Serguei Katkov
Date: 2023-06-16T11:52:46+07:00
New Revision: d119c386cd729ff07669c7b907f0738a27e2bde5
URL: https://github.com/llvm/llvm-project/commit/d119c386cd729ff07669c7b907f0738a27e2bde5
DIFF: https://github.com/llvm/llvm-project/commit/d119c386cd729ff07669c7b907f0738a27e2bde5.diff
LOG: [CGP] Additional tests for removing operand of assume. NFC.
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 b7c9c0c3d2867..ef7bb22c6d143 100644
--- a/llvm/test/Transforms/CodeGenPrepare/X86/delete-assume-dead-code.ll
+++ b/llvm/test/Transforms/CodeGenPrepare/X86/delete-assume-dead-code.ll
@@ -49,7 +49,7 @@ 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
+ %cmp2 = icmp sle i32 %iv2, %N
call void @llvm.assume(i1 %cmp2)
br i1 %cmp, label %exit, label %header
@@ -80,7 +80,7 @@ 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
+ %cmp2 = icmp sle i32 %iv2.inc, %N
call void @llvm.assume(i1 %cmp2)
br i1 %cmp, label %exit, label %header
@@ -88,5 +88,75 @@ exit:
ret i32 %iv
}
+; Two assumes case.
+define i32 @test4(i32 %N) nounwind {
+; CHECK-LABEL: @test4(
+; 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 sle i32 %iv2.inc, %N
+ call void @llvm.assume(i1 %cmp2)
+ %cmp3 = icmp sge i32 %iv2.inc, 0
+ call void @llvm.assume(i1 %cmp3)
+ br i1 %cmp, label %exit, label %header
+
+exit:
+ ret i32 %iv
+}
+
+; phi is used in assume and in compare.
+define i32 @test5(i32 %N, i32 %M) nounwind {
+; CHECK-LABEL: @test5(
+; 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: [[CMP3:%.*]] = icmp sge i32 [[IV2_INC]], [[M:%.*]]
+; CHECK-NEXT: [[CMP4:%.*]] = and i1 [[CMP]], [[CMP3]]
+; CHECK-NEXT: br i1 [[CMP4]], 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 sle i32 %iv2.inc, %N
+ call void @llvm.assume(i1 %cmp2)
+ %cmp3 = icmp sge i32 %iv2.inc, %M
+ %cmp4 = and i1 %cmp, %cmp3
+ br i1 %cmp4, 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