diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp index 369b052bf7a28..8961db50f9f84 100644 --- a/clang/lib/CodeGen/CGLoopInfo.cpp +++ b/clang/lib/CodeGen/CGLoopInfo.cpp @@ -334,11 +334,12 @@ LoopInfo::createLoopDistributeMetadata(const LoopAttributes &Attrs, if (Enabled != true) { SmallVector NewLoopProperties; if (Enabled == false) { - NewLoopProperties.append(LoopProperties.begin(), LoopProperties.end()); - NewLoopProperties.push_back( - MDNode::get(Ctx, {MDString::get(Ctx, "llvm.loop.distribute.enable"), - ConstantAsMetadata::get(ConstantInt::get( - llvm::Type::getInt1Ty(Ctx), 0))})); + NewLoopProperties.append( + LoopProperties.begin(), LoopProperties.end()); + NewLoopProperties.push_back(MDNode::get( + Ctx, + {MDString::get( + Ctx, "llvm.loop.distribute.disable")})); LoopProperties = NewLoopProperties; } return createLoopVectorizeMetadata(Attrs, LoopProperties, @@ -347,16 +348,15 @@ LoopInfo::createLoopDistributeMetadata(const LoopAttributes &Attrs, bool FollowupHasTransforms = false; SmallVector Followup = - createLoopVectorizeMetadata(Attrs, LoopProperties, FollowupHasTransforms); + createLoopVectorizeMetadata( + Attrs, LoopProperties, FollowupHasTransforms); SmallVector Args; Args.append(LoopProperties.begin(), LoopProperties.end()); - Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.distribute.enable"), - ConstantAsMetadata::get(ConstantInt::get( - llvm::Type::getInt1Ty(Ctx), - (Attrs.DistributeEnable == LoopAttributes::Enable)))}; - Args.push_back(MDNode::get(Ctx, Vals)); + Args.push_back(MDNode::get( + Ctx, + {MDString::get(Ctx, "llvm.loop.distribute.enable")})); if (FollowupHasTransforms) Args.push_back( diff --git a/clang/test/CodeGenCXX/pragma-followup_inner.cpp b/clang/test/CodeGenCXX/pragma-followup_inner.cpp index 04f5656dcd638..2cf2dba5b913d 100644 --- a/clang/test/CodeGenCXX/pragma-followup_inner.cpp +++ b/clang/test/CodeGenCXX/pragma-followup_inner.cpp @@ -22,7 +22,7 @@ extern "C" void followup_inner(int n, int *x) { // CHECK-DAG: ![[INNERLOOP_3]] = distinct !{![[INNERLOOP_3]], ![[PARALLEL_ACCESSES_4:[0-9]+]], ![[DISTRIBUTE_5:[0-9]+]], ![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]]} // CHECK-DAG: ![[PARALLEL_ACCESSES_4]] = !{!"llvm.loop.parallel_accesses", ![[ACCESSGROUP_2]]} -// CHECK-DAG: ![[DISTRIBUTE_5]] = !{!"llvm.loop.distribute.enable", i1 true} +// CHECK-DAG: ![[DISTRIBUTE_5]] = !{!"llvm.loop.distribute.enable"} // CHECK-DAG: ![[DISTRIBUTE_FOLLOWUP_6]] = !{!"llvm.loop.distribute.followup_all", ![[PARALLEL_ACCESSES_4]], ![[VECTORIZE_8:[0-9]+]]} // CHECK-DAG: ![[VECTORIZE_8]] = !{!"llvm.loop.vectorize.enable", i1 true} diff --git a/clang/test/CodeGenCXX/pragma-followup_outer.cpp b/clang/test/CodeGenCXX/pragma-followup_outer.cpp index fdd5a07d00857..2e907fb814b3d 100644 --- a/clang/test/CodeGenCXX/pragma-followup_outer.cpp +++ b/clang/test/CodeGenCXX/pragma-followup_outer.cpp @@ -19,7 +19,7 @@ extern "C" void followup_outer(int n, int *x) { // CHECK-DAG: ![[LOOP_3:[0-9]+]] = distinct !{![[LOOP_3:[0-9]+]], [[MP:![0-9]+]], ![[PARALLEL_ACCESSES_4:[0-9]+]], ![[DISTRIBUTE_5:[0-9]+]], ![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]]} // CHECK-DAG: ![[PARALLEL_ACCESSES_4:[0-9]+]] = !{!"llvm.loop.parallel_accesses", ![[ACCESSGROUP_2]]} -// CHECK-DAG: ![[DISTRIBUTE_5:[0-9]+]] = !{!"llvm.loop.distribute.enable", i1 true} +// CHECK-DAG: ![[DISTRIBUTE_5:[0-9]+]] = !{!"llvm.loop.distribute.enable"} // CHECK-DAG: ![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]] = !{!"llvm.loop.distribute.followup_all", [[MP]], ![[PARALLEL_ACCESSES_4:[0-9]+]], ![[VECTORIZE_8:[0-9]+]], ![[VECTORIZE_FOLLOWUP_9:[0-9]+]]} // CHECK-DAG: ![[VECTORIZE_8:[0-9]+]] = !{!"llvm.loop.vectorize.enable", i1 true} diff --git a/clang/test/CodeGenCXX/pragma-loop-distribute.cpp b/clang/test/CodeGenCXX/pragma-loop-distribute.cpp index 98aef21da2acd..66f0fb07b51fb 100644 --- a/clang/test/CodeGenCXX/pragma-loop-distribute.cpp +++ b/clang/test/CodeGenCXX/pragma-loop-distribute.cpp @@ -20,5 +20,5 @@ void while_test(int *List, int Length, int *List2, int Length2) { } // CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], [[MP:![0-9]+]], ![[DISTRIBUTE_ENABLE:.*]]} -// CHECK: ![[DISTRIBUTE_ENABLE]] = !{!"llvm.loop.distribute.enable", i1 true} +// CHECK: ![[DISTRIBUTE_ENABLE]] = !{!"llvm.loop.distribute.enable"} // CHECK: [[LOOP_2]] = distinct !{[[LOOP_2]], [[MP]]} diff --git a/clang/test/CodeGenCXX/pragma-loop.cpp b/clang/test/CodeGenCXX/pragma-loop.cpp index 8cb3346247daf..f9106725ad99d 100644 --- a/clang/test/CodeGenCXX/pragma-loop.cpp +++ b/clang/test/CodeGenCXX/pragma-loop.cpp @@ -248,7 +248,7 @@ void for_test_interleave_vectorize_disable_unroll(int *List, int Length) { // CHECK-DAG: ![[UNROLL_32:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 32} // CHECK-DAG: ![[UNROLL_FULL:[0-9]+]] = !{!"llvm.loop.unroll.full"} -// CHECK-DAG: ![[DISTRIBUTE_DISABLE:[0-9]+]] = !{!"llvm.loop.distribute.enable", i1 false} +// CHECK-DAG: ![[DISTRIBUTE_DISABLE:[0-9]+]] = !{!"llvm.loop.distribute.disable"} // CHECK-DAG: ![[INTERLEAVE_2:[0-9]+]] = !{!"llvm.loop.interleave.count", i32 2} // CHECK-DAG: ![[INTERLEAVE_4:[0-9]+]] = !{!"llvm.loop.interleave.count", i32 4} diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 86325ef731381..bfd1d70e49ad1 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -8128,18 +8128,17 @@ this is only performed if the entire loop cannot be vectorized due to unsafe memory dependencies. The transformation will attempt to isolate the unsafe dependencies into their own loop. -This metadata can be used to selectively enable or disable distribution of the -loop. The first operand is the string ``llvm.loop.distribute.enable`` and the -second operand is a bit. If the bit operand value is 1 distribution is -enabled. A value of 0 disables distribution: +This metadata can be used to selectively enable or disable +distribution of the loop. Each node has a single operand +containing the name string: .. code-block:: llvm - !0 = !{!"llvm.loop.distribute.enable", i1 0} - !1 = !{!"llvm.loop.distribute.enable", i1 1} + !0 = !{!"llvm.loop.distribute.enable"} + !1 = !{!"llvm.loop.distribute.disable"} -This metadata should be used in conjunction with ``llvm.loop`` loop -identification metadata. +This metadata should be used in conjunction with ``llvm.loop`` +loop identification metadata. '``llvm.loop.distribute.followup_coincident``' Metadata ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 2b9efd22131c6..ca5354930b018 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -2901,14 +2901,9 @@ void LoopAccessInfo::emitUnsafeDependenceRemark() { LLVM_DEBUG(dbgs() << "LAA: unsafe dependent memory operations in loop\n"); // Emit remark for first unsafe dependence - bool HasForcedDistribution = false; - std::optional Value = - findStringMetadataForLoop(TheLoop, "llvm.loop.distribute.enable"); - if (Value) { - const MDOperand *Op = *Value; - assert(Op && mdconst::hasa(*Op) && "invalid metadata"); - HasForcedDistribution = mdconst::extract(*Op)->getZExtValue(); - } + bool HasForcedDistribution = + getBooleanLoopAttribute( + TheLoop, "llvm.loop.distribute.enable"); const std::string Info = HasForcedDistribution diff --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp index 00eac14845c57..006cc43de3ca5 100644 --- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp @@ -938,14 +938,11 @@ class LoopDistributeForLoop { /// Check whether the loop metadata is forcing distribution to be /// enabled/disabled. void setForced() { - std::optional Value = - findStringMetadataForLoop(L, "llvm.loop.distribute.enable"); - if (!Value) - return; - - const MDOperand *Op = *Value; - assert(Op && mdconst::hasa(*Op) && "invalid metadata"); - IsForced = mdconst::extract(*Op)->getZExtValue(); + if (getBooleanLoopAttribute(L, "llvm.loop.distribute.enable")) + IsForced = true; + else if (getBooleanLoopAttribute( + L, "llvm.loop.distribute.disable")) + IsForced = false; } Loop *L; diff --git a/llvm/lib/Transforms/Utils/LoopConstrainer.cpp b/llvm/lib/Transforms/Utils/LoopConstrainer.cpp index 72fae62e56e88..74cd2a729d285 100644 --- a/llvm/lib/Transforms/Utils/LoopConstrainer.cpp +++ b/llvm/lib/Transforms/Utils/LoopConstrainer.cpp @@ -453,7 +453,8 @@ static void DisableAllLoopOptsOnLoop(Loop &L) { Context, {MDString::get(Context, "llvm.loop.licm_versioning.disable")}); MDNode *DisableDistribution = MDNode::get( Context, - {MDString::get(Context, "llvm.loop.distribute.enable"), FalseVal}); + {MDString::get( + Context, "llvm.loop.distribute.disable")}); MDNode *NewLoopID = MDNode::get(Context, {Dummy, DisableUnroll, DisableVectorize, DisableLICMVersioning, DisableDistribution}); diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 7573467917c73..290bd73fa2c18 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -429,6 +429,9 @@ TransformationMode llvm::hasVectorizeTransformation(const Loop *L) { } TransformationMode llvm::hasDistributeTransformation(const Loop *L) { + if (getBooleanLoopAttribute(L, "llvm.loop.distribute.disable")) + return TM_SuppressedByUser; + if (getBooleanLoopAttribute(L, "llvm.loop.distribute.enable")) return TM_ForcedByUser; diff --git a/llvm/test/Analysis/LoopAccessAnalysis/pr64637.ll b/llvm/test/Analysis/LoopAccessAnalysis/pr64637.ll index d3e589cf99cf3..7b25d1fffcbba 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/pr64637.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/pr64637.ll @@ -76,4 +76,4 @@ for.body: ; preds = %for.body, %for.body } !0 = distinct !{!0, !1} -!1 = !{!"llvm.loop.distribute.enable", i1 true} +!1 = !{!"llvm.loop.distribute.enable"} diff --git a/llvm/test/Other/optimization-remarks-lazy-bfi.ll b/llvm/test/Other/optimization-remarks-lazy-bfi.ll index c5099bb2179e4..5fc34cc14bdc8 100644 --- a/llvm/test/Other/optimization-remarks-lazy-bfi.ll +++ b/llvm/test/Other/optimization-remarks-lazy-bfi.ll @@ -75,7 +75,7 @@ for.cond.cleanup: !18 = !DILocation(line: 4, column: 5, scope: !7) !19 = !DILocation(line: 4, column: 10, scope: !7) !20 = distinct !{!20, !21} -!21 = !{!"llvm.loop.distribute.enable", i1 true} +!21 = !{!"llvm.loop.distribute.enable"} !22 = !{!"function_entry_count", i64 3} !23 = !{!"branch_weights", i32 99, i32 1} !24 = !{!"branch_weights", i32 1, i32 99} diff --git a/llvm/test/Transforms/IRCE/add-metadata-pre-post-loops.ll b/llvm/test/Transforms/IRCE/add-metadata-pre-post-loops.ll index eb72907730c6d..3a360814e361e 100644 --- a/llvm/test/Transforms/IRCE/add-metadata-pre-post-loops.ll +++ b/llvm/test/Transforms/IRCE/add-metadata-pre-post-loops.ll @@ -76,7 +76,7 @@ attributes #0 = { alwaysinline } !3 = !{!"llvm.loop.unroll.disable"} !4 = !{!"llvm.loop.vectorize.enable", i1 false} !5 = !{!"llvm.loop.licm_versioning.disable"} -!6 = !{!"llvm.loop.distribute.enable", i1 false} +!6 = !{!"llvm.loop.distribute.disable"} !7 = !{} !8 = distinct !{!8, !3, !4, !5} !9 = distinct !{!9, !3, !4, !5} diff --git a/llvm/test/Transforms/IRCE/correct-loop-info.ll b/llvm/test/Transforms/IRCE/correct-loop-info.ll index c75de167681ad..b1ce5383b24b8 100644 --- a/llvm/test/Transforms/IRCE/correct-loop-info.ll +++ b/llvm/test/Transforms/IRCE/correct-loop-info.ll @@ -181,6 +181,6 @@ declare void @pluto() !1 = !{!"llvm.loop.unroll.disable"} !2 = !{!"llvm.loop.vectorize.enable", i1 false} !3 = !{!"llvm.loop.licm_versioning.disable"} -!4 = !{!"llvm.loop.distribute.enable", i1 false} +!4 = !{!"llvm.loop.distribute.disable"} !5 = !{} !6 = distinct !{!6, !1, !2, !3, !4} diff --git a/llvm/test/Transforms/IRCE/loop-guarded-bounds.ll b/llvm/test/Transforms/IRCE/loop-guarded-bounds.ll index ea169987cf2fc..61cfef6f1492a 100644 --- a/llvm/test/Transforms/IRCE/loop-guarded-bounds.ll +++ b/llvm/test/Transforms/IRCE/loop-guarded-bounds.ll @@ -130,7 +130,7 @@ exit: ; preds = %guarded, %loop_, %prehead ; CHECK: [[META1]] = !{!"llvm.loop.unroll.disable"} ; CHECK: [[META2]] = !{!"llvm.loop.vectorize.enable", i1 false} ; CHECK: [[META3]] = !{!"llvm.loop.licm_versioning.disable"} -; CHECK: [[META4]] = !{!"llvm.loop.distribute.enable", i1 false} +; CHECK: [[META4]] = !{!"llvm.loop.distribute.disable"} ; CHECK: [[META5]] = !{} ; CHECK: [[LOOP6]] = distinct !{[[LOOP6]], [[META1]], [[META2]], [[META3]], [[META4]]} ;. diff --git a/llvm/test/Transforms/IRCE/pre_post_loops.ll b/llvm/test/Transforms/IRCE/pre_post_loops.ll index da2faa34719af..2807adba35940 100644 --- a/llvm/test/Transforms/IRCE/pre_post_loops.ll +++ b/llvm/test/Transforms/IRCE/pre_post_loops.ll @@ -163,7 +163,7 @@ exit: ; CHECK: [[META2]] = !{!"llvm.loop.unroll.disable"} ; CHECK: [[META3]] = !{!"llvm.loop.vectorize.enable", i1 false} ; CHECK: [[META4]] = !{!"llvm.loop.licm_versioning.disable"} -; CHECK: [[META5]] = !{!"llvm.loop.distribute.enable", i1 false} +; CHECK: [[META5]] = !{!"llvm.loop.distribute.disable"} ; CHECK: [[META6]] = !{} ; CHECK: [[LOOP7]] = distinct !{[[LOOP7]], [[META2]], [[META3]], [[META4]], [[META5]]} ;. diff --git a/llvm/test/Transforms/IRCE/range_intersect_miscompile.ll b/llvm/test/Transforms/IRCE/range_intersect_miscompile.ll index 68613feacba32..2e21bb5ad0bd0 100644 --- a/llvm/test/Transforms/IRCE/range_intersect_miscompile.ll +++ b/llvm/test/Transforms/IRCE/range_intersect_miscompile.ll @@ -490,7 +490,7 @@ deopt: ; preds = %range_check_block ; CHECK: [[META1]] = !{!"llvm.loop.unroll.disable"} ; CHECK: [[META2]] = !{!"llvm.loop.vectorize.enable", i1 false} ; CHECK: [[META3]] = !{!"llvm.loop.licm_versioning.disable"} -; CHECK: [[META4]] = !{!"llvm.loop.distribute.enable", i1 false} +; CHECK: [[META4]] = !{!"llvm.loop.distribute.disable"} ; CHECK: [[META5]] = !{} ; CHECK: [[LOOP6]] = distinct !{[[LOOP6]], [[META1]], [[META2]], [[META3]], [[META4]]} ; CHECK: [[RNG7]] = !{i32 0, i32 50} diff --git a/llvm/test/Transforms/IRCE/unsigned_comparisons_ugt.ll b/llvm/test/Transforms/IRCE/unsigned_comparisons_ugt.ll index 7236cf4817ade..cdd7235ac45b4 100644 --- a/llvm/test/Transforms/IRCE/unsigned_comparisons_ugt.ll +++ b/llvm/test/Transforms/IRCE/unsigned_comparisons_ugt.ll @@ -447,7 +447,7 @@ exit: ; CHECK: [[META2]] = !{!"llvm.loop.unroll.disable"} ; CHECK: [[META3]] = !{!"llvm.loop.vectorize.enable", i1 false} ; CHECK: [[META4]] = !{!"llvm.loop.licm_versioning.disable"} -; CHECK: [[META5]] = !{!"llvm.loop.distribute.enable", i1 false} +; CHECK: [[META5]] = !{!"llvm.loop.distribute.disable"} ; CHECK: [[META6]] = !{} ; CHECK: [[LOOP7]] = distinct !{[[LOOP7]], [[META2]], [[META3]], [[META4]], [[META5]]} ; CHECK: [[LOOP8]] = distinct !{[[LOOP8]], [[META2]], [[META3]], [[META4]], [[META5]]} diff --git a/llvm/test/Transforms/IRCE/unsigned_comparisons_ult.ll b/llvm/test/Transforms/IRCE/unsigned_comparisons_ult.ll index 546e1b0faa1c3..107a3554282ad 100644 --- a/llvm/test/Transforms/IRCE/unsigned_comparisons_ult.ll +++ b/llvm/test/Transforms/IRCE/unsigned_comparisons_ult.ll @@ -654,7 +654,7 @@ exit: ; CHECK: [[META2]] = !{!"llvm.loop.unroll.disable"} ; CHECK: [[META3]] = !{!"llvm.loop.vectorize.enable", i1 false} ; CHECK: [[META4]] = !{!"llvm.loop.licm_versioning.disable"} -; CHECK: [[META5]] = !{!"llvm.loop.distribute.enable", i1 false} +; CHECK: [[META5]] = !{!"llvm.loop.distribute.disable"} ; CHECK: [[META6]] = !{} ; CHECK: [[LOOP7]] = distinct !{[[LOOP7]], [[META2]], [[META3]], [[META4]], [[META5]]} ; CHECK: [[LOOP8]] = distinct !{[[LOOP8]], [[META2]], [[META3]], [[META4]], [[META5]]} diff --git a/llvm/test/Transforms/Inline/dilocation-loop-metadata-update.ll b/llvm/test/Transforms/Inline/dilocation-loop-metadata-update.ll index 1bc132663331b..0d8dcfbcf2a8b 100644 --- a/llvm/test/Transforms/Inline/dilocation-loop-metadata-update.ll +++ b/llvm/test/Transforms/Inline/dilocation-loop-metadata-update.ll @@ -47,7 +47,7 @@ entry: !7 = !DILocation(line: 6, column: 3, scope: !3) !8 = !DILocation(line: 7, column: 22, scope: !3) !9 = !{!"llvm.loop.mustprogress"} -!10 = !{!"llvm.loop.distribute.enable", i1 true} +!10 = !{!"llvm.loop.distribute.enable"} !11 = !{!"llvm.loop.distribute.followup_all", !7, !8, !9, !12, !13, !14} !12 = !{!"llvm.loop.vectorize.width", i32 8} !13 = !{!"llvm.loop.vectorize.enable", i1 true} @@ -66,7 +66,7 @@ entry: ; CHECK: [[META7]] = !DILocation(line: 6, column: 3, scope: [[DBG3]]) ; CHECK: [[META8]] = !DILocation(line: 7, column: 22, scope: [[DBG3]]) ; CHECK: [[META9]] = !{!"llvm.loop.mustprogress"} -; CHECK: [[META10]] = !{!"llvm.loop.distribute.enable", i1 true} +; CHECK: [[META10]] = !{!"llvm.loop.distribute.enable"} ; CHECK: [[META11]] = !{!"llvm.loop.distribute.followup_all", [[META7]], [[META8]], [[META9]], [[META12:![0-9]+]], [[META13:![0-9]+]], [[META14:![0-9]+]]} ; CHECK: [[META12]] = !{!"llvm.loop.vectorize.width", i32 8} ; CHECK: [[META13]] = !{!"llvm.loop.vectorize.enable", i1 true} diff --git a/llvm/test/Transforms/LoopDistribute/basic-with-memchecks.ll b/llvm/test/Transforms/LoopDistribute/basic-with-memchecks.ll index 2828882afe779..dcd231a900ee2 100644 --- a/llvm/test/Transforms/LoopDistribute/basic-with-memchecks.ll +++ b/llvm/test/Transforms/LoopDistribute/basic-with-memchecks.ll @@ -288,5 +288,5 @@ attributes #0 = { nounwind readnone convergent } attributes #1 = { nounwind convergent } !0 = distinct !{!0, !1} -!1 = !{!"llvm.loop.distribute.enable", i1 true} +!1 = !{!"llvm.loop.distribute.enable"} ; CHECK: ![[PROF1]] = !{!"unknown", !"loop-versioning"} diff --git a/llvm/test/Transforms/LoopDistribute/diagnostics-with-hotness.ll b/llvm/test/Transforms/LoopDistribute/diagnostics-with-hotness.ll index b5ef3578eadd9..4f2f76191e615 100644 --- a/llvm/test/Transforms/LoopDistribute/diagnostics-with-hotness.ll +++ b/llvm/test/Transforms/LoopDistribute/diagnostics-with-hotness.ll @@ -74,7 +74,7 @@ for.cond.cleanup: !18 = !DILocation(line: 4, column: 5, scope: !7) !19 = !DILocation(line: 4, column: 10, scope: !7) !20 = distinct !{!20, !21} -!21 = !{!"llvm.loop.distribute.enable", i1 true} +!21 = !{!"llvm.loop.distribute.enable"} !22 = !{!"function_entry_count", i64 3} !23 = !{!"branch_weights", i32 2000, i32 1} !24 = !{!"branch_weights", i32 1, i32 99} diff --git a/llvm/test/Transforms/LoopDistribute/diagnostics.ll b/llvm/test/Transforms/LoopDistribute/diagnostics.ll index e6a0d83bd63d2..80b217d0abb2b 100644 --- a/llvm/test/Transforms/LoopDistribute/diagnostics.ll +++ b/llvm/test/Transforms/LoopDistribute/diagnostics.ll @@ -194,7 +194,7 @@ attributes #1 = { nounwind convergent } !18 = !DILocation(line: 4, column: 5, scope: !7) !19 = !DILocation(line: 4, column: 10, scope: !7) !20 = distinct !{!20, !21} -!21 = !{!"llvm.loop.distribute.enable", i1 true} +!21 = !{!"llvm.loop.distribute.enable"} !22 = distinct !DISubprogram(name: "not_forced", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2) !23 = !DILocation(line: 9, column: 20, scope: !22) !24 = !DILocation(line: 9, column: 3, scope: !22) diff --git a/llvm/test/Transforms/LoopDistribute/disable_nonforced_enable.ll b/llvm/test/Transforms/LoopDistribute/disable_nonforced_enable.ll index 45a2d31256a27..eff1621cd7ada 100644 --- a/llvm/test/Transforms/LoopDistribute/disable_nonforced_enable.ll +++ b/llvm/test/Transforms/LoopDistribute/disable_nonforced_enable.ll @@ -43,4 +43,4 @@ for.end: ret void } -!0 = distinct !{!0, !{!"llvm.loop.disable_nonforced"}, !{!"llvm.loop.distribute.enable", i32 1}} +!0 = distinct !{!0, !{!"llvm.loop.disable_nonforced"}, !{!"llvm.loop.distribute.enable"}} diff --git a/llvm/test/Transforms/LoopDistribute/early-exit.ll b/llvm/test/Transforms/LoopDistribute/early-exit.ll index 9353d842523f4..d2ad9b1bcd6c5 100644 --- a/llvm/test/Transforms/LoopDistribute/early-exit.ll +++ b/llvm/test/Transforms/LoopDistribute/early-exit.ll @@ -89,4 +89,4 @@ attributes #0 = { nounwind readnone convergent } attributes #1 = { nounwind convergent } !0 = distinct !{!0, !1} -!1 = !{!"llvm.loop.distribute.enable", i1 true} +!1 = !{!"llvm.loop.distribute.enable"} diff --git a/llvm/test/Transforms/LoopDistribute/followup.ll b/llvm/test/Transforms/LoopDistribute/followup.ll index ae418ad9e6b42..2753bad5e1c1e 100644 --- a/llvm/test/Transforms/LoopDistribute/followup.ll +++ b/llvm/test/Transforms/LoopDistribute/followup.ll @@ -125,7 +125,7 @@ for.end: } !0 = distinct !{!0, !1, !2, !3, !4, !5} -!1 = !{!"llvm.loop.distribute.enable", i1 true} +!1 = !{!"llvm.loop.distribute.enable"} !2 = !{!"llvm.loop.distribute.followup_all", !{!"FollowupAll"}} !3 = !{!"llvm.loop.distribute.followup_coincident", !{!"FollowupCoincident", i1 false}} !4 = !{!"llvm.loop.distribute.followup_sequential", !{!"FollowupSequential", i32 8}} diff --git a/llvm/test/Transforms/LoopDistribute/metadata.ll b/llvm/test/Transforms/LoopDistribute/metadata.ll index b0e461fe0ea75..8b74ac4249550 100644 --- a/llvm/test/Transforms/LoopDistribute/metadata.ll +++ b/llvm/test/Transforms/LoopDistribute/metadata.ll @@ -131,6 +131,6 @@ for.end: ; preds = %for.body } !0 = distinct !{!0, !1} -!1 = !{!"llvm.loop.distribute.enable", i1 true} +!1 = !{!"llvm.loop.distribute.enable"} !2 = distinct !{!2, !3} -!3 = !{!"llvm.loop.distribute.enable", i1 false} +!3 = !{!"llvm.loop.distribute.disable"} diff --git a/llvm/test/Transforms/LoopSimplify/preserve-llvm-loop-metadata.ll b/llvm/test/Transforms/LoopSimplify/preserve-llvm-loop-metadata.ll index 2c1dff7ee5a5f..049880a97a211 100644 --- a/llvm/test/Transforms/LoopSimplify/preserve-llvm-loop-metadata.ll +++ b/llvm/test/Transforms/LoopSimplify/preserve-llvm-loop-metadata.ll @@ -65,6 +65,6 @@ cleanup: ; preds = %cleanup.loopexit, % } !0 = distinct !{!0, !1} -!1 = !{!"llvm.loop.distribute.enable", i1 true} +!1 = !{!"llvm.loop.distribute.enable"} ; CHECK: !0 = distinct !{!0, !1} -; CHECK: !1 = !{!"llvm.loop.distribute.enable", i1 true} +; CHECK: !1 = !{!"llvm.loop.distribute.enable"} diff --git a/llvm/test/Transforms/SimplifyCFG/preserve-llvm-loop-metadata.ll b/llvm/test/Transforms/SimplifyCFG/preserve-llvm-loop-metadata.ll index a95b6ec15b129..ec87c9635dc32 100644 --- a/llvm/test/Transforms/SimplifyCFG/preserve-llvm-loop-metadata.ll +++ b/llvm/test/Transforms/SimplifyCFG/preserve-llvm-loop-metadata.ll @@ -147,7 +147,7 @@ while.end: ; preds = %while.cond !0 = !{i32 2, !"Debug Info Version", i32 3} !1 = distinct !{!1, !2} -!2 = !{!"llvm.loop.distribute.enable", i1 true} +!2 = !{!"llvm.loop.distribute.enable"} !3 = distinct !{!3, !4} !4 = !{!"llvm.loop.mustprogress"} !5 = distinct !{!5, !4, !6} @@ -161,7 +161,7 @@ while.end: ; preds = %while.cond !13 = !DILocation(line: 9, column: 23, scope: !12) ; CHECK: !1 = distinct !{!1, !2} -; CHECK: !2 = !{!"llvm.loop.distribute.enable", i1 true} +; CHECK: !2 = !{!"llvm.loop.distribute.enable"} ; CHECK: !3 = distinct !{!3, !4} ; CHECK: !4 = !{!"llvm.loop.mustprogress"} ; CHECK: !5 = distinct !{!5, !4, !6} diff --git a/llvm/unittests/Analysis/LoopInfoTest.cpp b/llvm/unittests/Analysis/LoopInfoTest.cpp index 4828573c32c10..5321f72aa1784 100644 --- a/llvm/unittests/Analysis/LoopInfoTest.cpp +++ b/llvm/unittests/Analysis/LoopInfoTest.cpp @@ -72,7 +72,7 @@ TEST(LoopInfoTest, LoopWithSingleLatch) { " ret void\n" "}\n" "!0 = distinct !{!0, !1}\n" - "!1 = !{!\"llvm.loop.distribute.enable\", i1 true}\n"; + "!1 = !{!\"llvm.loop.distribute.enable\"}\n"; // Parse the module. LLVMContext Context; @@ -122,7 +122,7 @@ TEST(LoopInfoTest, LoopWithMultipleLatches) { " ret void\n" "}\n" "!0 = distinct !{!0, !1}\n" - "!1 = !{!\"llvm.loop.distribute.enable\", i1 true}\n"; + "!1 = !{!\"llvm.loop.distribute.enable\"}\n"; // Parse the module. LLVMContext Context; @@ -1397,7 +1397,7 @@ TEST(LoopInfoTest, LoopUniqueExitBlocks) { " ret void\n" "}\n" "!0 = distinct !{!0, !1}\n" - "!1 = !{!\"llvm.loop.distribute.enable\", i1 true}\n"; + "!1 = !{!\"llvm.loop.distribute.enable\"}\n"; // Parse the module. LLVMContext Context; @@ -1440,7 +1440,7 @@ TEST(LoopInfoTest, LoopNonLatchUniqueExitBlocks) { " ret void\n" "}\n" "!0 = distinct !{!0, !1}\n" - "!1 = !{!\"llvm.loop.distribute.enable\", i1 true}\n"; + "!1 = !{!\"llvm.loop.distribute.enable\"}\n"; // Parse the module. LLVMContext Context; diff --git a/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp b/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp index e4905423347a2..4022afc433a61 100644 --- a/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp +++ b/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp @@ -358,8 +358,10 @@ FailureOr LoopMetadataConversion::convertLICMAttr() { } FailureOr LoopMetadataConversion::convertDistributeAttr() { - FailureOr disable = - lookupBoolNode("llvm.loop.distribute.enable", true); + FailureOr disable = lookupBooleanUnitNode( + "llvm.loop.distribute.enable", + "llvm.loop.distribute.disable", + /*negated=*/true); FailureOr followupCoincident = lookupFollowupNode("llvm.loop.distribute.followup_coincident"); FailureOr followupSequential = diff --git a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp index f3ec18c9074e4..41ba31106f788 100644 --- a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp @@ -162,7 +162,12 @@ void LoopAnnotationConversion::convertLoopOptions(LoopLICMAttr options) { } void LoopAnnotationConversion::convertLoopOptions(LoopDistributeAttr options) { - convertBoolNode("llvm.loop.distribute.enable", options.getDisable(), true); + if (auto disable = options.getDisable()) { + if (disable.getValue()) + addUnitNode("llvm.loop.distribute.disable"); + else + addUnitNode("llvm.loop.distribute.enable"); + } convertFollowupNode("llvm.loop.distribute.followup_coincident", options.getFollowupCoincident()); convertFollowupNode("llvm.loop.distribute.followup_sequential", diff --git a/mlir/test/Target/LLVMIR/Import/metadata-loop.ll b/mlir/test/Target/LLVMIR/Import/metadata-loop.ll index 20431a7412bd1..62cf5dd3e1605 100644 --- a/mlir/test/Target/LLVMIR/Import/metadata-loop.ll +++ b/mlir/test/Target/LLVMIR/Import/metadata-loop.ll @@ -219,7 +219,7 @@ end: } !1 = distinct !{!1, !2, !3, !4, !5, !6} -!2 = !{!"llvm.loop.distribute.enable", i1 0} +!2 = !{!"llvm.loop.distribute.disable"} !3 = !{!"llvm.loop.distribute.followup_coincident", !9} !4 = !{!"llvm.loop.distribute.followup_sequential", !9} !5 = !{!"llvm.loop.distribute.followup_fallback", !9} diff --git a/mlir/test/Target/LLVMIR/loop-metadata.mlir b/mlir/test/Target/LLVMIR/loop-metadata.mlir index 2fe4a994aeb66..a0636cfe90297 100644 --- a/mlir/test/Target/LLVMIR/loop-metadata.mlir +++ b/mlir/test/Target/LLVMIR/loop-metadata.mlir @@ -185,7 +185,7 @@ llvm.func @distributeOptions() { // CHECK-DAG: ![[NON_FORCED:[0-9]+]] = !{!"llvm.loop.disable_nonforced"} // CHECK-DAG: ![[FOLLOWUP:[0-9]+]] = distinct !{![[FOLLOWUP]], ![[NON_FORCED]]} // CHECK-DAG: ![[LOOP_NODE]] = distinct !{![[LOOP_NODE]], !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}} -// CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.distribute.enable", i1 false} +// CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.distribute.disable"} // CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.distribute.followup_coincident", ![[FOLLOWUP]]} // CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.distribute.followup_sequential", ![[FOLLOWUP]]} // CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.distribute.followup_fallback", ![[FOLLOWUP]]}