-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Fix loop_annotation name in unit tests #172934
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
base: main
Are you sure you want to change the base?
Conversation
|
@llvm/pr-subscribers-mlir Author: Fei Peng (fiigii) ChangesThe attribute name is Full diff: https://github.com/llvm/llvm-project/pull/172934.diff 1 Files Affected:
diff --git a/mlir/test/Conversion/SCFToControlFlow/convert-to-cfg.mlir b/mlir/test/Conversion/SCFToControlFlow/convert-to-cfg.mlir
index 0c4f20e8d1a04..d697acfccb2e5 100644
--- a/mlir/test/Conversion/SCFToControlFlow/convert-to-cfg.mlir
+++ b/mlir/test/Conversion/SCFToControlFlow/convert-to-cfg.mlir
@@ -710,9 +710,9 @@ func.func @forall(%num_threads: index) {
// CHECK: ^[[bb3]](%{{.*}}: index):
// CHECK: cf.cond_br %{{.*}}, ^[[bb4:.*]], ^[[bb5:.*]]
// CHECK: ^[[bb4]]:
-// CHECK: cf.br ^[[bb3]]({{.*}}) {llvm.loop_annotation = #[[FULL_UNROLL]]}
+// CHECK: cf.br ^[[bb3]]({{.*}}) {loop_annotation = #[[FULL_UNROLL]]}
// CHECK: ^[[bb5]]:
-// CHECK: cf.br ^[[bb1]]({{.*}}) {llvm.loop_annotation = #[[NO_UNROLL]]}
+// CHECK: cf.br ^[[bb1]]({{.*}}) {loop_annotation = #[[NO_UNROLL]]}
// CHECK: ^[[bb6]]:
// CHECK: return
#no_unroll = #llvm.loop_annotation<unroll = <disable = true>>
@@ -724,8 +724,8 @@ func.func @simple_std_for_loops_annotation(%arg0 : index, %arg1 : index, %arg2 :
%c4 = arith.constant 4 : index
scf.for %i1 = %c0 to %c4 step %c1 {
%c1_0 = arith.constant 1 : index
- } {llvm.loop_annotation = #full_unroll}
- } {llvm.loop_annotation = #no_unroll}
+ } {loop_annotation = #full_unroll}
+ } {loop_annotation = #no_unroll}
return
}
@@ -735,7 +735,7 @@ func.func @simple_std_for_loops_annotation(%arg0 : index, %arg1 : index, %arg2 :
// CHECK: #[[NO_UNROLL:.*]] = #llvm.loop_annotation<unroll = #[[LOOP_UNROLL_DISABLE]]>
// CHECK: func @simple_while_loops_annotation
// CHECK: cf.br
-// CHECK: cf.cond_br {{.*}} {llvm.loop_annotation = #[[NO_UNROLL]]}
+// CHECK: cf.cond_br {{.*}} {loop_annotation = #[[NO_UNROLL]]}
// CHECK: return
#no_unroll = #llvm.loop_annotation<unroll = <disable = true>>
func.func @simple_while_loops_annotation(%arg0 : i1) {
@@ -743,7 +743,7 @@ func.func @simple_while_loops_annotation(%arg0 : i1) {
scf.condition(%arg0)
} do {
scf.yield
- } attributes {llvm.loop_annotation = #no_unroll}
+ } attributes {loop_annotation = #no_unroll}
return
}
@@ -754,7 +754,7 @@ func.func @simple_while_loops_annotation(%arg0 : i1) {
// CHECK: func @do_while_loops_annotation
// CHECK: cf.br
// CHECK: cf.cond_br
-// CHECK: cf.br {{.*}} {llvm.loop_annotation = #[[NO_UNROLL]]}
+// CHECK: cf.br {{.*}} {loop_annotation = #[[NO_UNROLL]]}
// CHECK: return
#no_unroll = #llvm.loop_annotation<unroll = <disable = true>>
func.func @do_while_loops_annotation() {
@@ -765,7 +765,7 @@ func.func @do_while_loops_annotation() {
} do {
^bb0(%arg2: i32):
scf.yield %c0_i32: i32
- } attributes {llvm.loop_annotation = #no_unroll}
+ } attributes {loop_annotation = #no_unroll}
return
}
|
|
This is a valid update. I do not have permission to approve this PR; perhaps others can assist. |
ftynse
left a comment
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.
What problem does this solve?
This is a confusing test. I was trying to control loop unrolling at the MLIR level and was confused by the distinction between Additionally, I hope MLIR clarifies it in the language reference. |
|
I think we have a more fundamental problem here where this all works "by accident". The However the It turns out that we copy LLVM dialect attributes when lowering SCF to CF: However here we check just for the dialect of the attribute (value) and not the key, so we propagate a discardable attribute whose key just collide with the inherent attribute of the LLVM branch. |
|
Agree. I was also confused by the code above, and intentionally processing LLVM dialect in SCF/CF dialects seems not very reasonable. I am not very familiar with MLIR, based on my experience in handling LLVM metadata, we may need a more generic and clearer approach, for example:
|
The attribute name is
loop_annotationinstead ofllvm.loop_annotation.