-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[mlir][arith] Add comparison integration tests #96974
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
@llvm/pr-subscribers-mlir-arith @llvm/pr-subscribers-mlir Author: Jacob Yu (pingshiyu) ChangesComparison operations regression tests, from the original larger PR that has been broken down: #92272 Full diff: https://github.com/llvm/llvm-project/pull/96974.diff 1 Files Affected:
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/comparison.mlir b/mlir/test/Integration/Dialect/Arith/CPU/comparison.mlir
new file mode 100644
index 0000000000000..85b70b2cad5a0
--- /dev/null
+++ b/mlir/test/Integration/Dialect/Arith/CPU/comparison.mlir
@@ -0,0 +1,61 @@
+// Tests comparison operations.
+// These tests are intended to be target agnostic: they should yield the same results
+// regardless of the target platform.
+
+// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \
+// RUN: --convert-func-to-llvm --convert-arith-to-llvm | \
+// RUN: mlir-cpu-runner -e entry -entry-point-result=void \
+// RUN: --shared-libs=%mlir_c_runner_utils | \
+// RUN: FileCheck %s --match-full-lines
+
+func.func @signed_comparison_on_i1s() {
+ // signed comparisons on i1s
+ // slt 0 1 = false, sle 0 1 = false, sgt 0 1 = true, sge 0 1 = true
+ // CHECK: 0
+ // CHECK-NEXT: 0
+ // CHECK-NEXT: 1
+ // CHECK-NEXT: 1
+ %false = arith.constant false
+ %true = arith.constant true
+ %0 = arith.cmpi slt, %false, %true : i1
+ %1 = arith.cmpi sle, %false, %true : i1
+ %2 = arith.cmpi sgt, %false, %true : i1
+ %3 = arith.cmpi sge, %false, %true : i1
+ vector.print %0 : i1
+ vector.print %1 : i1
+ vector.print %2 : i1
+ vector.print %3 : i1
+ return
+}
+
+func.func @sge_0_1_is_true() {
+ // sge 0 -1, sge 0 1, should be true
+ // sge 0 -1 == sge 0 1 == true (1)
+ // CHECK-NEXT: 1
+ // CHECK-NEXT: 1
+ %false = arith.constant 0 : i1
+ %true = arith.constant 1 : i1
+ %true_0 = arith.constant -1 : i1
+ %0 = arith.cmpi sge, %false, %true : i1
+ %1 = arith.cmpi sge, %false, %true_0 : i1
+ vector.print %0 : i1
+ vector.print %1 : i1
+ return
+}
+
+func.func @zero_ult_min_index() {
+ // 0 `ult` -2^63 = true
+ // CHECK-NEXT: 1
+ %c0 = arith.constant 0 : index
+ %c-9223372036854775808 = arith.constant -9223372036854775808 : index
+ %0 = arith.cmpi ult, %c0, %c-9223372036854775808 : index
+ vector.print %0 : i1
+ return
+}
+
+func.func @entry() {
+ func.call @signed_comparison_on_i1s() : () -> ()
+ func.call @sge_0_1_is_true() : () -> ()
+ func.call @zero_ult_min_index() : () -> ()
+ return
+}
|
Thanks! Could you try to structure this similarly that what you did for #96973? Similar comment re variable names (prefer underscores to hyphens) and re where to place It might be easier to finish #96973 and #96975 first, and then just replicate the style that we establish there. |
Yep that's the plan! Once the other two PRs are done I'll use the same style as used there (and for the rest of the tests) |
I've just pushed a commit updating this with the formats we established in the other PRs. If everyone is generally happy with the format now and has no further comments, please tick it, and I'll apply the same changes to the other regressions! |
I do like the structure (thanks!), but also have a few more comments. I will be sending these shortly. I won't be commenting on other PRs to avoid repetition. [nit] Please follow https://mlir.llvm.org/getting_started/Contributing/#commit-messages, which links to https://cbea.ms/git-commit/. So, instead of:
it would be:
|
@banach-space would you be able to take a look at this one too please, and tick if LGTY? |
Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
…vm-project into arith-regression-comparison
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.
[nit] "Add comparison regression tests " -> these are usually referred to as either "integration" or "e2e" (end-to-end) tests :)
Co-authored-by: Andrzej Warzyński <andrzej.warzynski@gmail.com>
…vm-project into arith-regression-comparison
c115e67
to
3cb8377
Compare
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.
Just a few small suggestions
thank you @banach-space I've pushed a commit to address the comments :) |
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.
A couple more small suggestions. We are getting there 🙏🏻
@banach-space Thanks for the most recent comments! I've just pushed a commit adding some extra tests and addressing the other comment - please give a tick if all looks good now! |
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, thank you for all the updates and for bearing with me 🙏🏻
Great thank you @banach-space ! One down... 4 more to go 💀 @kuhar would you please be able to have a look as well and if you're happy, tick and merge? (I don't have merge rights) |
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
Comparison operations regression tests, from the original larger PR that has been broken down: #92272