-
Notifications
You must be signed in to change notification settings - Fork 14.3k
ValueTracking/test: increase recurrence coverage #108836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The shift-recurrence-knownbits.ll test file only covers shift instructions while testing recurrence patterns with knownbits. Add tests for add, sub, mul, and, and or as well, and rename the file recurrence-knownbits.ll.
@llvm/pr-subscribers-llvm-analysis Author: Ramkumar Ramachandra (artagnon) ChangesThe shift-recurrence-knownbits.ll test file only covers shift instructions while testing recurrence patterns with knownbits. Add tests for add, sub, mul, and, and or as well, and rename the file recurrence-knownbits.ll. Full diff: https://github.com/llvm/llvm-project/pull/108836.diff 1 Files Affected:
diff --git a/llvm/test/Analysis/ValueTracking/shift-recurrence-knownbits.ll b/llvm/test/Analysis/ValueTracking/recurrence-knownbits.ll
similarity index 65%
rename from llvm/test/Analysis/ValueTracking/shift-recurrence-knownbits.ll
rename to llvm/test/Analysis/ValueTracking/recurrence-knownbits.ll
index 5e9084aac31a38..3355328cad9ecf 100644
--- a/llvm/test/Analysis/ValueTracking/shift-recurrence-knownbits.ll
+++ b/llvm/test/Analysis/ValueTracking/recurrence-knownbits.ll
@@ -21,6 +21,106 @@ exit:
ret i64 %res
}
+define i64 @test_add(i1 %c) {
+; CHECK-LABEL: @test_add(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: ret i64 0
+;
+entry:
+ br label %loop
+loop:
+ %iv = phi i64 [8, %entry], [%iv.next, %loop]
+ %iv.next = add nuw i64 %iv, 4
+ br i1 %c, label %exit, label %loop
+exit:
+ %res = and i64 %iv, 1
+ ret i64 %res
+}
+
+define i64 @test_sub(i1 %c) {
+; CHECK-LABEL: @test_sub(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: ret i64 0
+;
+entry:
+ br label %loop
+loop:
+ %iv = phi i64 [8, %entry], [%iv.next, %loop]
+ %iv.next = sub nuw i64 %iv, 4
+ br i1 %c, label %exit, label %loop
+exit:
+ %res = and i64 %iv, 1
+ ret i64 %res
+}
+
+define i64 @test_mul(i1 %c) {
+; CHECK-LABEL: @test_mul(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: ret i64 0
+;
+entry:
+ br label %loop
+loop:
+ %iv = phi i64 [8, %entry], [%iv.next, %loop]
+ %iv.next = mul i64 %iv, 2
+ br i1 %c, label %exit, label %loop
+exit:
+ %res = and i64 %iv, 2
+ ret i64 %res
+}
+
+define i64 @test_and(i1 %c) {
+; CHECK-LABEL: @test_and(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: ret i64 2047
+;
+entry:
+ br label %loop
+loop:
+ %iv = phi i64 [1025, %entry], [%iv.next, %loop]
+ %iv.next = and i64 %iv, 1024
+ br i1 %c, label %exit, label %loop
+exit:
+ %res = or i64 %iv, 1023
+ ret i64 %res
+}
+
+define i64 @test_or(i1 %c) {
+; CHECK-LABEL: @test_or(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: ret i64 2047
+;
+entry:
+ br label %loop
+loop:
+ %iv = phi i64 [1025, %entry], [%iv.next, %loop]
+ %iv.next = or i64 %iv, 1024
+ br i1 %c, label %exit, label %loop
+exit:
+ %res = or i64 %iv, 1023
+ ret i64 %res
+}
+
define i64 @test_ashr_zeros(i1 %c) {
; CHECK-LABEL: @test_ashr_zeros(
; CHECK-NEXT: entry:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I didn't try to confirm that the tests are not present elsewhere (a way to do that is to comment out the relevant cases and run tests...)
I did that part of course, and there is some existing but scattered coverage that isn't reduced: I thought it would be good to have a collection of tests testing the recurrence patterns in one place, as a prelude to adding support for other BinOps. Note that although the switch statement has support for FMul, it is impossible to test, as (I think) KnownBits doesn't work with fp values. |
The shift-recurrence-knownbits.ll test file only covers shift instructions while testing recurrence patterns with knownbits. Add tests for add, sub, mul, and, and or as well, and rename the file recurrence-knownbits.ll.
The shift-recurrence-knownbits.ll test file only covers shift instructions while testing recurrence patterns with knownbits. Add tests for add, sub, mul, and, and or as well, and rename the file recurrence-knownbits.ll.