-
Notifications
You must be signed in to change notification settings - Fork 13.5k
SCEV: cover a codepath in isImpliedCondBalancedTypes #123070
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 code that checks a predicate against a swapped predicate in isImpliedCondBalancedTypes is not covered by any existing test, within any Analysis or Transform. Fix this by adding a test to SCEV.
@llvm/pr-subscribers-llvm-analysis Author: Ramkumar Ramachandra (artagnon) ChangesThe code that checks a predicate against a swapped predicate in isImpliedCondBalancedTypes is not covered by any existing test, within any Analysis or Transform. Fix this by adding a test to SCEV. -- 8< -- Full diff: https://github.com/llvm/llvm-project/pull/123070.diff 1 Files Affected:
diff --git a/llvm/test/Analysis/ScalarEvolution/implied-via-division.ll b/llvm/test/Analysis/ScalarEvolution/implied-via-division.ll
index fbe69b4b188977..3fd59299ed81c9 100644
--- a/llvm/test/Analysis/ScalarEvolution/implied-via-division.ll
+++ b/llvm/test/Analysis/ScalarEvolution/implied-via-division.ll
@@ -411,3 +411,56 @@ header:
exit:
ret void
}
+
+define void @swapped_predicate(i32 %n) nounwind {
+; Prove that (n >= 1) ===> (0 >= -n / 2).
+; CHECK-LABEL: 'swapped_predicate'
+; CHECK-NEXT: Determining loop execution counts for: @swapped_predicate
+; CHECK-NEXT: Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
+; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741824
+; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (1 + %n.div.2)<nsw>
+; CHECK-NEXT: Loop %header: Trip multiple is 1
+;
+entry:
+ %cmp1 = icmp sge i32 %n, 1
+ %n.div.2 = sdiv i32 %n, 2
+ call void(i1, ...) @llvm.experimental.guard(i1 %cmp1) [ "deopt"() ]
+ br label %header
+
+header:
+ %indvar = phi i32 [ %indvar.next, %header ], [ 0, %entry ]
+ %indvar.next = add i32 %indvar, 1
+ %minus.indvar = sub nsw i32 0, %indvar
+ %minus.n.div.2 = sub nsw i32 0, %n.div.2
+ %exitcond = icmp sge i32 %minus.indvar, %minus.n.div.2
+ br i1 %exitcond, label %header, label %exit
+
+exit:
+ ret void
+}
+
+define void @swapped_predicate_neg(i32 %n) nounwind {
+; Prove that (n >= 1) =\=> (-n / 2 >= 0).
+; CHECK-LABEL: 'swapped_predicate_neg'
+; CHECK-NEXT: Determining loop execution counts for: @swapped_predicate_neg
+; CHECK-NEXT: Loop %header: Unpredictable backedge-taken count.
+; CHECK-NEXT: Loop %header: Unpredictable constant max backedge-taken count.
+; CHECK-NEXT: Loop %header: Unpredictable symbolic max backedge-taken count.
+;
+entry:
+ %cmp1 = icmp sge i32 %n, 1
+ %n.div.2 = sdiv i32 %n, 2
+ call void(i1, ...) @llvm.experimental.guard(i1 %cmp1) [ "deopt"() ]
+ br label %header
+
+header:
+ %indvar = phi i32 [ %indvar.next, %header ], [ 0, %entry ]
+ %indvar.next = add i32 %indvar, 1
+ %minus.indvar = sub nsw i32 0, %indvar
+ %minus.n.div.2 = sub nsw i32 0, %n.div.2
+ %exitcond = icmp sge i32 %minus.n.div.2, %minus.indvar
+ br i1 %exitcond, label %header, label %exit
+
+exit:
+ ret void
+}
|
Gentle ping. |
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
The code that checks a predicate against a swapped predicate in isImpliedCondBalancedTypes is not covered by any existing test, within any Analysis or Transform. Fix this by adding a test to SCEV.