https://github.com/madhur13490 updated https://github.com/llvm/llvm-project/pull/213902
>From 31cd99c8031427fe0788ff07088e0a1b619c4945 Mon Sep 17 00:00:00 2001 From: Madhur Amilkanthwar <[email protected]> Date: Mon, 3 Aug 2026 01:39:14 -0700 Subject: [PATCH] Enforce single-operand form for llvm.loop.vectorize.predicate metadata Replace the two-operand boolean form !{!"llvm.loop.vectorize.predicate.enable", i1 0/1} with a single-operand enable/disable pair: !{!"llvm.loop.vectorize.predicate.enable"} !{!"llvm.loop.vectorize.predicate.disable"} The Verifier rejects the two-operand form, AutoUpgrade rewrites old bitcode, and the readers and producers in LLVM, Clang and MLIR are updated. Please refer to RFC: https://discourse.llvm.org/t/rfc-enforce-single-operand-format-for-all-enable-metadata-nodes/90571/ --- clang/lib/CodeGen/CGLoopInfo.cpp | 10 +- .../test/CodeGenCXX/pragma-loop-predicate.cpp | 4 +- llvm/docs/LangRef.md | 9 +- llvm/include/llvm/IR/AutoUpgrade.h | 12 +-- llvm/lib/IR/AutoUpgrade.cpp | 92 +++++++++--------- llvm/lib/IR/Verifier.cpp | 9 ++ .../Vectorize/LoopVectorizationLegality.cpp | 4 + ...upgrade-loop-vectorize-predicate-enable.ll | 37 +++++++ ...rade-loop-vectorize-predicate-enable.ll.bc | Bin 0 -> 2368 bytes .../AArch64/low_trip_count_predicates.ll | 2 +- .../partial-reduce-dot-product-epilogue.ll | 2 +- .../partial-reduce-dot-product-mixed.ll | 2 +- .../partial-reduce-dot-product-neon.ll | 2 +- .../AArch64/partial-reduce-dot-product.ll | 2 +- .../AArch64/partial-reduce-sub.ll | 2 +- .../LoopVectorize/AArch64/partial-reduce.ll | 2 +- .../LoopVectorize/AArch64/predicated-costs.ll | 2 +- .../LoopVectorize/AArch64/strict-fadd.ll | 2 +- .../LoopVectorize/AArch64/sve2-histcnt.ll | 2 +- .../AArch64/tail-folding-styles.ll | 2 +- .../widen-gep-all-indices-invariant.ll | 2 +- .../ARM/prefer-tail-loop-folding.ll | 2 +- .../ARM/tail-folding-loop-hint.ll | 2 +- .../ARM/tail-folding-prefer-flag.ll | 2 +- .../VPlan/AArch64/sve-tail-folding-forced.ll | 2 +- .../VPlan/AArch64/vplan-printing.ll | 4 +- .../LoopVectorize/VPlan/constant-fold.ll | 2 +- .../LoopVectorize/X86/induction-costs.ll | 2 +- .../X86/tail_folding_and_assume_safety.ll | 4 +- .../LoopVectorize/X86/tail_loop_folding.ll | 4 +- ...o-fold-tail-by-masking-iv-external-uses.ll | 2 +- .../LoopVectorize/reduction-inloop-uf4.ll | 2 +- .../LoopVectorize/reduction-inloop.ll | 2 +- .../use-scalar-epilogue-if-tp-fails.ll | 2 +- ...kedge-elimination-predicated-early-exit.ll | 2 +- .../Verifier/llvm.loop.vectorize.predicate.ll | 41 ++++++++ .../Target/LLVMIR/LoopAnnotationImporter.cpp | 3 +- .../LLVMIR/LoopAnnotationTranslation.cpp | 36 ++++--- .../Target/LLVMIR/Import/metadata-loop.ll | 2 +- mlir/test/Target/LLVMIR/loop-metadata.mlir | 2 +- 40 files changed, 208 insertions(+), 111 deletions(-) create mode 100644 llvm/test/Bitcode/upgrade-loop-vectorize-predicate-enable.ll create mode 100644 llvm/test/Bitcode/upgrade-loop-vectorize-predicate-enable.ll.bc create mode 100644 llvm/test/Verifier/llvm.loop.vectorize.predicate.ll diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp index 93857f9aaab8d..23eff005f7004 100644 --- a/clang/lib/CodeGen/CGLoopInfo.cpp +++ b/clang/lib/CodeGen/CGLoopInfo.cpp @@ -226,11 +226,11 @@ clang::CodeGen::LoopInfo::createLoopVectorizeMetadata( IsVectorPredicateEnabled = (Attrs.VectorizePredicateEnable == LoopAttributes::Enable); - Metadata *Vals[] = { - MDString::get(Ctx, "llvm.loop.vectorize.predicate.enable"), - ConstantAsMetadata::get(ConstantInt::get(llvm::Type::getInt1Ty(Ctx), - IsVectorPredicateEnabled))}; - Args.push_back(MDNode::get(Ctx, Vals)); + Args.push_back(MDNode::get( + Ctx, + {MDString::get(Ctx, IsVectorPredicateEnabled + ? "llvm.loop.vectorize.predicate.enable" + : "llvm.loop.vectorize.predicate.disable")})); } // Setting vectorize.width diff --git a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp index 421110fd9f867..cb7dfdb810215 100644 --- a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp +++ b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp @@ -106,10 +106,10 @@ void test9(int *List, int Length) { // CHECK-NEXT: [[GEN3]] = !{!"llvm.loop.vectorize.enable"} // CHECK-NEXT: ![[LOOP1]] = distinct !{![[LOOP1]], [[MP]], [[GEN6:![0-9]+]], [[GEN3]]} -// CHECK-NEXT: [[GEN6]] = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +// CHECK-NEXT: [[GEN6]] = !{!"llvm.loop.vectorize.predicate.enable"} // CHECK-NEXT: ![[LOOP2]] = distinct !{![[LOOP2]], [[MP]], [[GEN8:![0-9]+]], [[GEN3]]} -// CHECK-NEXT: [[GEN8]] = !{!"llvm.loop.vectorize.predicate.enable", i1 false} +// CHECK-NEXT: [[GEN8]] = !{!"llvm.loop.vectorize.predicate.disable"} // CHECK-NEXT: ![[LOOP3]] = distinct !{![[LOOP3]], [[MP]], [[GEN6]], [[GEN3]]} diff --git a/llvm/docs/LangRef.md b/llvm/docs/LangRef.md index 1fc6ea1a7ed9d..7cf9169cd3fbd 100644 --- a/llvm/docs/LangRef.md +++ b/llvm/docs/LangRef.md @@ -8071,14 +8071,11 @@ node has a single operand containing the name string: This metadata selectively enables or disables creating predicated instructions for the loop, which can enable folding of the scalar epilogue loop into the -main loop. The first operand is the string -`llvm.loop.vectorize.predicate.enable` and the second operand is a bit. If -the bit operand value is 1 predication is enabled. A value of 0 disables -predication: +main loop. Each node has a single operand containing the name string: ```llvm -!0 = !{!"llvm.loop.vectorize.predicate.enable", i1 0} -!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 1} +!0 = !{!"llvm.loop.vectorize.predicate.enable"} +!1 = !{!"llvm.loop.vectorize.predicate.disable"} ``` Additionally, enabling predication implicitly enables vectorization. diff --git a/llvm/include/llvm/IR/AutoUpgrade.h b/llvm/include/llvm/IR/AutoUpgrade.h index 12aeb2793f705..8f10733de4ae5 100644 --- a/llvm/include/llvm/IR/AutoUpgrade.h +++ b/llvm/include/llvm/IR/AutoUpgrade.h @@ -112,14 +112,14 @@ namespace llvm { /// Check whether a string looks like an old loop attachment tag. inline bool mayBeOldLoopAttachmentTag(StringRef Name) { - // "llvm.loop.distribute.enable" and "llvm.loop.vectorize.enable" are - // intentionally included: the current single-operand form shares the tag - // with the removed two-operand form (!{!"...", i1 X}), so we can only - // decide by inspecting the operands, which happens in - // upgradeLoopArgument(). + // The enable tags below are intentionally included: the current + // single-operand form shares the tag with the removed two-operand form + // (!{!"...", i1 X}), so we can only decide by inspecting the operands, + // which happens in upgradeLoopArgument(). return Name.starts_with("llvm.vectorizer.") || Name == "llvm.loop.distribute.enable" || - Name == "llvm.loop.vectorize.enable"; + Name == "llvm.loop.vectorize.enable" || + Name == "llvm.loop.vectorize.predicate.enable"; } /// Upgrade the loop attachment metadata node. diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index f2a2ddbfc2e31..e7262ccaf4505 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -7011,37 +7011,46 @@ void llvm::copyModuleAttrToFunctions(Module &M) { } } -// Old two-operand form: !{!"llvm.loop.distribute.enable", i1 X}. The new -// single-operand form uses "llvm.loop.distribute.enable" for X = true and -// "llvm.loop.distribute.disable" for X = false. -static bool isOldDistributeEnable(const MDTuple *T) { - if (T->getNumOperands() != 2) - return false; - auto *Tag = dyn_cast_or_null<MDString>(T->getOperand(0)); - if (!Tag || Tag->getString() != "llvm.loop.distribute.enable") - return false; - return mdconst::hasa<ConstantInt>(T->getOperand(1)); +namespace { +// Single-operand tags replacing a removed two-operand form +// !{!"<Enable>", i1 X}: X = true selects Enable, X = false selects Disable. +struct BooleanLoopTags { + StringLiteral Enable; + StringLiteral Disable; +}; +} // namespace + +static constexpr BooleanLoopTags OldBooleanLoopTags[] = { + {"llvm.loop.distribute.enable", "llvm.loop.distribute.disable"}, + {"llvm.loop.vectorize.enable", "llvm.loop.vectorize.disable"}, + {"llvm.loop.vectorize.predicate.enable", + "llvm.loop.vectorize.predicate.disable"}}; + +// Return the replacement tags for the enable tag \p Name, or nullptr. +static const BooleanLoopTags *findBooleanLoopTags(StringRef Name) { + const auto *Tags = + find_if(OldBooleanLoopTags, [Name](const BooleanLoopTags &Candidate) { + return Candidate.Enable == Name; + }); + return Tags == std::end(OldBooleanLoopTags) ? nullptr : Tags; } -/// Old two-operand form: !{!"llvm.loop.vectorize.enable", i1 X}. The new -/// single-operand form uses "llvm.loop.vectorize.enable" for X = true and -/// "llvm.loop.vectorize.disable" for X = false. -static bool isOldVectorizeEnable(const MDTuple *T) { - if (T->getNumOperands() != 2) - return false; +// Return the replacement tags if \p T still uses a removed two-operand form. +static const BooleanLoopTags *getOldBooleanLoopTags(const MDTuple *T) { + if (T->getNumOperands() != 2 || !mdconst::hasa<ConstantInt>(T->getOperand(1))) + return nullptr; auto *Tag = dyn_cast_or_null<MDString>(T->getOperand(0)); - if (!Tag || Tag->getString() != "llvm.loop.vectorize.enable") - return false; - return mdconst::hasa<ConstantInt>(T->getOperand(1)); + return Tag ? findBooleanLoopTags(Tag->getString()) : nullptr; } -/// Build the single-operand vectorize enable/disable node that replaces a -/// boolean operand: nonzero -> enable, zero -> disable. -static Metadata *makeVectorizeEnableNode(LLVMContext &C, const MDOperand &Op) { +/// Build the single-operand node that replaces a boolean operand: nonzero +/// selects the enable tag, zero the disable tag. +static Metadata *makeBooleanLoopNode(LLVMContext &C, + const BooleanLoopTags &Tags, + const MDOperand &Op) { bool Enable = !mdconst::extract<ConstantInt>(Op)->isZero(); - return MDTuple::get( - C, {MDString::get(C, Enable ? "llvm.loop.vectorize.enable" - : "llvm.loop.vectorize.disable")}); + return MDTuple::get(C, + {MDString::get(C, Enable ? Tags.Enable : Tags.Disable)}); } static bool isOldLoopArgument(Metadata *MD) { @@ -7055,7 +7064,7 @@ static bool isOldLoopArgument(Metadata *MD) { return false; if (S->getString().starts_with("llvm.vectorizer.")) return true; - return isOldDistributeEnable(T) || isOldVectorizeEnable(T); + return getOldBooleanLoopTags(T) != nullptr; } static MDString *upgradeLoopTag(LLVMContext &C, StringRef OldTag) { @@ -7082,18 +7091,9 @@ static Metadata *upgradeLoopArgument(Metadata *MD) { LLVMContext &C = T->getContext(); - // Rewrite the old two-operand distribute form to the single-operand pair. - if (isOldDistributeEnable(T)) { - bool Enable = !mdconst::extract<ConstantInt>(T->getOperand(1))->isZero(); - return MDTuple::get( - C, {MDString::get(C, Enable ? "llvm.loop.distribute.enable" - : "llvm.loop.distribute.disable")}); - } - - // Rewrite the modern two-operand vectorize.enable form to the single-operand - // enable/disable pair. - if (isOldVectorizeEnable(T)) - return makeVectorizeEnableNode(C, T->getOperand(1)); + // Rewrite a removed two-operand boolean form to the single-operand pair. + if (const BooleanLoopTags *Tags = getOldBooleanLoopTags(T)) + return makeBooleanLoopNode(C, *Tags, T->getOperand(1)); if (!OldTag->getString().starts_with("llvm.vectorizer.")) return MD; @@ -7103,9 +7103,9 @@ static Metadata *upgradeLoopArgument(Metadata *MD) { // The legacy !{!"llvm.vectorizer.enable", i1 X} maps onto the single-operand // vectorize.enable/disable pair, not a two-operand enable node. - if (NewTag->getString() == "llvm.loop.vectorize.enable" && - T->getNumOperands() == 2 && mdconst::hasa<ConstantInt>(T->getOperand(1))) - return makeVectorizeEnableNode(C, T->getOperand(1)); + if (T->getNumOperands() == 2 && mdconst::hasa<ConstantInt>(T->getOperand(1))) + if (const BooleanLoopTags *Tags = findBooleanLoopTags(NewTag->getString())) + return makeBooleanLoopNode(C, *Tags, T->getOperand(1)); SmallVector<Metadata *, 8> Ops; Ops.reserve(T->getNumOperands()); @@ -7124,14 +7124,14 @@ MDNode *llvm::upgradeInstructionLoopAttachment(MDNode &N) { if (none_of(T->operands(), isOldLoopArgument)) return &N; - // Fix the old two-operand distribute/vectorize.enable nodes in place: the - // Verifier rejects any MDNode carrying those tags with more than one operand, - // so a leftover reference (from the distinct loop-ID) would still trigger a - // diagnostic. In-place mutation is safe on distinct MDNodes. + // Fix the removed two-operand boolean nodes in place: the Verifier rejects + // any MDNode carrying those tags with more than one operand, so a leftover + // reference (from the distinct loop-ID) would still trigger a diagnostic. + // In-place mutation is safe on distinct MDNodes. if (T->isDistinct()) { for (unsigned I = 0, E = T->getNumOperands(); I < E; ++I) { auto *OpT = dyn_cast_or_null<MDTuple>(T->getOperand(I)); - if (OpT && (isOldDistributeEnable(OpT) || isOldVectorizeEnable(OpT))) + if (OpT && getOldBooleanLoopTags(OpT)) T->replaceOperandWith(I, upgradeLoopArgument(OpT)); } if (none_of(T->operands(), isOldLoopArgument)) diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 516d99b7fbc69..5580aa73698ef 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -1024,6 +1024,15 @@ void Verifier::visitMDNode(const MDNode &BaseMD, Check(CurrentMD->getNumOperands() == 1, "Expecting only the metadata name", CurrentMD); + // Enforce the single-operand form of the vectorize predication metadata. + if (CurrentMD->getNumOperands() > 0 && + (CurrentMD->getOperand(0).equalsStr( + "llvm.loop.vectorize.predicate.enable") || + CurrentMD->getOperand(0).equalsStr( + "llvm.loop.vectorize.predicate.disable"))) + Check(CurrentMD->getNumOperands() == 1, + "Expecting only the metadata name", CurrentMD); + // Check these last, so we diagnose problems in operands first. Check(!CurrentMD->isTemporary(), "Expected no forward declarations!", CurrentMD); diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp index 9086880599231..82fe38a235c87 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp @@ -293,6 +293,10 @@ void LoopVectorizeHints::getHintsFromMetadata() { Force.Value = FK_Enabled; else if (Name == "llvm.loop.vectorize.disable") Force.Value = FK_Disabled; + else if (Name == "llvm.loop.vectorize.predicate.enable") + Predicate.Value = FK_Enabled; + else if (Name == "llvm.loop.vectorize.predicate.disable") + Predicate.Value = FK_Disabled; continue; } if (Args.size() == 1) diff --git a/llvm/test/Bitcode/upgrade-loop-vectorize-predicate-enable.ll b/llvm/test/Bitcode/upgrade-loop-vectorize-predicate-enable.ll new file mode 100644 index 0000000000000..20e1f264e559c --- /dev/null +++ b/llvm/test/Bitcode/upgrade-loop-vectorize-predicate-enable.ll @@ -0,0 +1,37 @@ +; Test that older bitcode carrying the two-operand form of +; "llvm.loop.vectorize.predicate.enable" is auto-upgraded to the +; single-operand enable/disable pair on load. +; +; RUN: llvm-dis < %s.bc | FileCheck %s +; RUN: verify-uselistorder < %s.bc + +define void @enable_true() { +entry: + br label %body +body: + br i1 0, label %body, label %exit, !llvm.loop !0 +exit: + ret void +} + +define void @enable_false() { +entry: + br label %body +body: + br i1 0, label %body, label %exit, !llvm.loop !2 +exit: + ret void +} + +; i1 true -> single-operand enable. +; i1 false -> disable. +; CHECK: !{!"llvm.loop.vectorize.predicate.enable"} +; CHECK: !{!"llvm.loop.vectorize.predicate.disable"} +; The old two-operand nodes must be gone from the module. +; CHECK-NOT: llvm.loop.vectorize.predicate.enable", i1 +; CHECK-NOT: llvm.loop.vectorize.predicate.disable", i1 + +!0 = distinct !{!0, !1} +!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!2 = distinct !{!2, !3} +!3 = !{!"llvm.loop.vectorize.predicate.enable", i1 false} diff --git a/llvm/test/Bitcode/upgrade-loop-vectorize-predicate-enable.ll.bc b/llvm/test/Bitcode/upgrade-loop-vectorize-predicate-enable.ll.bc new file mode 100644 index 0000000000000000000000000000000000000000..d8de6672e251bca832b2fa87a4b5980618df926e GIT binary patch literal 2368 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 aJ0vUn(3i?S^rf;7Z6Da!-(RW>p??9IL0519 literal 0 HcmV?d00001 diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/low_trip_count_predicates.ll b/llvm/test/Transforms/LoopVectorize/AArch64/low_trip_count_predicates.ll index 1138b19bd3471..c68421ac4a2a4 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/low_trip_count_predicates.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/low_trip_count_predicates.ll @@ -528,7 +528,7 @@ exit: !0 = distinct !{!0, !1} -!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!1 = !{!"llvm.loop.vectorize.predicate.enable"} !2 = !{!"branch_weights", i32 10, i32 30} ;. diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-epilogue.ll b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-epilogue.ll index 0282a9cac5c8d..f493914d294a1 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-epilogue.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-epilogue.ll @@ -447,7 +447,7 @@ exit: !7 = distinct !{!7, !8, !9, !10} !8 = !{!"llvm.loop.mustprogress"} -!9 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!9 = !{!"llvm.loop.vectorize.predicate.enable"} !10 = !{!"llvm.loop.vectorize.enable"} attributes #0 = { vscale_range(1,16) "target-features"="+sve" } diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-mixed.ll b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-mixed.ll index 339aea4551d6b..97cc8e50b62c7 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-mixed.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-mixed.ll @@ -393,7 +393,7 @@ for.exit: !7 = distinct !{!7, !8, !9, !10} !8 = !{!"llvm.loop.mustprogress"} -!9 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!9 = !{!"llvm.loop.vectorize.predicate.enable"} !10 = !{!"llvm.loop.vectorize.enable"} attributes #0 = { vscale_range(1,16) "target-features"="+sve" } attributes #1 = { "target-features"="+neon" } diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-neon.ll b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-neon.ll index 3ba46e2fd46d6..aa9ca9a265605 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-neon.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-neon.ll @@ -2394,5 +2394,5 @@ exit: !7 = distinct !{!7, !8, !9, !10} !8 = !{!"llvm.loop.mustprogress"} -!9 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!9 = !{!"llvm.loop.vectorize.predicate.enable"} !10 = !{!"llvm.loop.vectorize.enable"} diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product.ll b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product.ll index f19db4519c09a..c074982766e6d 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product.ll @@ -2691,7 +2691,7 @@ for.body: !7 = distinct !{!7, !8, !9, !10} !8 = !{!"llvm.loop.mustprogress"} -!9 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!9 = !{!"llvm.loop.vectorize.predicate.enable"} !10 = !{!"llvm.loop.vectorize.enable"} attributes #0 = { vscale_range(1,16) "target-features"="+sve" } attributes #1 = { vscale_range(1,16) "target-features"="+neon,+dotprod,+sve" "target-cpu"="neoverse-v2" } diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-sub.ll b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-sub.ll index 641d6db59147d..61f4e4098a8bf 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-sub.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-sub.ll @@ -523,7 +523,7 @@ for.exit: !7 = distinct !{!7, !8, !9, !10} !8 = !{!"llvm.loop.mustprogress"} -!9 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!9 = !{!"llvm.loop.vectorize.predicate.enable"} !10 = !{!"llvm.loop.vectorize.enable"} attributes #0 = { vscale_range(1,16) "target-features"="+sve" } diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce.ll b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce.ll index 03938490e465c..9aa27cee2ecb8 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce.ll @@ -1285,7 +1285,7 @@ exit: !0 = distinct !{!0, !1} -!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!1 = !{!"llvm.loop.vectorize.predicate.enable"} attributes #0 = { vscale_range(1,16) "target-features"="+sve" } attributes #1 = { vscale_range(1,16) "target-features"="+neon,+dotprod,+sve" "target-cpu"="neoverse-v2" } attributes #2 = { "target-features"="+neon,+dotprod" } diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/predicated-costs.ll b/llvm/test/Transforms/LoopVectorize/AArch64/predicated-costs.ll index 3c47627e5f45f..31f6e49c835b9 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/predicated-costs.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/predicated-costs.ll @@ -370,7 +370,7 @@ attributes #1 = { "target-cpu"="neoverse-v2" } !0 = distinct !{!0, !1, !2, !3} !1 = !{!"llvm.loop.mustprogress"} -!2 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!2 = !{!"llvm.loop.vectorize.predicate.enable"} !3 = !{!"llvm.loop.vectorize.enable"} ; BFI computes if is taken 20 times, and loop 32 times. Make sure we round the diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/strict-fadd.ll b/llvm/test/Transforms/LoopVectorize/AArch64/strict-fadd.ll index b79cc7cf2bcee..b689914508b25 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/strict-fadd.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/strict-fadd.ll @@ -1417,5 +1417,5 @@ for.cond.cleanup: !9 = !{!"llvm.loop.interleave.count", i32 1} !10 = !{!"llvm.loop.interleave.count", i32 4} !11 = !{!"llvm.loop.vectorize.enable"} -!12 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!12 = !{!"llvm.loop.vectorize.predicate.enable"} !13 = distinct !{!13, !6, !9, !11} diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/sve2-histcnt.ll b/llvm/test/Transforms/LoopVectorize/AArch64/sve2-histcnt.ll index 2ec48b25af5b5..b6bef8c3fe15c 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/sve2-histcnt.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/sve2-histcnt.ll @@ -877,7 +877,7 @@ attributes #0 = { "target-features"="+sve2" vscale_range(1,16) } !0 = distinct !{!0, !1} !1 = !{!"llvm.loop.interleave.count", i32 2} !2 = distinct !{!2, !3} -!3 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!3 = !{!"llvm.loop.vectorize.predicate.enable"} !4 = distinct !{!4, !5} !5 = !{!"llvm.loop.interleave.count", i32 1} !6 = !{!7} diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/tail-folding-styles.ll b/llvm/test/Transforms/LoopVectorize/AArch64/tail-folding-styles.ll index 0b783375a33e1..d323dce104e66 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/tail-folding-styles.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/tail-folding-styles.ll @@ -150,7 +150,7 @@ while.end.loopexit: } !0 = distinct !{!0, !1, !2, !3, !4} -!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!1 = !{!"llvm.loop.vectorize.predicate.enable"} !2 = !{!"llvm.loop.vectorize.scalable.enable", i1 true} !3 = !{!"llvm.loop.interleave.count", i32 1} !4 = !{!"llvm.loop.vectorize.width", i32 4} diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/widen-gep-all-indices-invariant.ll b/llvm/test/Transforms/LoopVectorize/AArch64/widen-gep-all-indices-invariant.ll index 3b29335c36301..18712ad5d1fba 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/widen-gep-all-indices-invariant.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/widen-gep-all-indices-invariant.ll @@ -55,7 +55,7 @@ attributes #0 = { "target-cpu"="neoverse-v2" } !0 = distinct !{!0, !1, !2} !1 = !{!"llvm.loop.vectorize.enable"} -!2 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!2 = !{!"llvm.loop.vectorize.predicate.enable"} ;. ; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]} ; CHECK: [[META1]] = !{!"llvm.loop.isvectorized", i32 1} diff --git a/llvm/test/Transforms/LoopVectorize/ARM/prefer-tail-loop-folding.ll b/llvm/test/Transforms/LoopVectorize/ARM/prefer-tail-loop-folding.ll index 75862d9c72e00..46dbb741a1ee0 100644 --- a/llvm/test/Transforms/LoopVectorize/ARM/prefer-tail-loop-folding.ll +++ b/llvm/test/Transforms/LoopVectorize/ARM/prefer-tail-loop-folding.ll @@ -425,7 +425,7 @@ attributes #0 = { nofree norecurse nounwind "target-features"="+armv8.1-m.main,+ !6 = !{!"llvm.loop.vectorize.enable"} !7 = distinct !{!7, !8} -!8 = !{!"llvm.loop.vectorize.predicate.enable", i1 false} +!8 = !{!"llvm.loop.vectorize.predicate.disable"} !10 = distinct !{!10, !11} !11 = !{!"llvm.loop.vectorize.width", i32 4} diff --git a/llvm/test/Transforms/LoopVectorize/ARM/tail-folding-loop-hint.ll b/llvm/test/Transforms/LoopVectorize/ARM/tail-folding-loop-hint.ll index 3038b7fd935d3..e0bcaba596768 100644 --- a/llvm/test/Transforms/LoopVectorize/ARM/tail-folding-loop-hint.ll +++ b/llvm/test/Transforms/LoopVectorize/ARM/tail-folding-loop-hint.ll @@ -80,5 +80,5 @@ for.body: ; CHECK-NEXT: [[VEC_LOOP2]] = distinct !{[[VEC_LOOP2]], [[MD_IS_VEC]], [[MD_RT_UNROLL_DIS]]} !6 = distinct !{!6, !7, !8} -!7 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!7 = !{!"llvm.loop.vectorize.predicate.enable"} !8 = !{!"llvm.loop.vectorize.enable"} diff --git a/llvm/test/Transforms/LoopVectorize/ARM/tail-folding-prefer-flag.ll b/llvm/test/Transforms/LoopVectorize/ARM/tail-folding-prefer-flag.ll index a477fee265d59..8d4f990c09e84 100644 --- a/llvm/test/Transforms/LoopVectorize/ARM/tail-folding-prefer-flag.ll +++ b/llvm/test/Transforms/LoopVectorize/ARM/tail-folding-prefer-flag.ll @@ -101,7 +101,7 @@ for.body: } !10 = distinct !{!10, !11, !12} -!11 = !{!"llvm.loop.vectorize.predicate.enable", i1 false} +!11 = !{!"llvm.loop.vectorize.predicate.disable"} !12 = !{!"llvm.loop.vectorize.enable"} !14 = distinct !{!14, !15} diff --git a/llvm/test/Transforms/LoopVectorize/VPlan/AArch64/sve-tail-folding-forced.ll b/llvm/test/Transforms/LoopVectorize/VPlan/AArch64/sve-tail-folding-forced.ll index 592dbbb2b5c52..15e57eda91e0e 100644 --- a/llvm/test/Transforms/LoopVectorize/VPlan/AArch64/sve-tail-folding-forced.ll +++ b/llvm/test/Transforms/LoopVectorize/VPlan/AArch64/sve-tail-folding-forced.ll @@ -85,4 +85,4 @@ while.end.loopexit: attributes #0 = { "target-features"="+sve" } !0 = distinct !{!0, !1} -!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!1 = !{!"llvm.loop.vectorize.predicate.enable"} diff --git a/llvm/test/Transforms/LoopVectorize/VPlan/AArch64/vplan-printing.ll b/llvm/test/Transforms/LoopVectorize/VPlan/AArch64/vplan-printing.ll index 5445a5e835fb6..91cb168e423ef 100644 --- a/llvm/test/Transforms/LoopVectorize/VPlan/AArch64/vplan-printing.ll +++ b/llvm/test/Transforms/LoopVectorize/VPlan/AArch64/vplan-printing.ll @@ -282,5 +282,5 @@ exit: !0 = distinct !{!0, !2, !3} !1 = distinct !{!1, !2, !4} !2 = !{!"llvm.loop.interleave.count", i32 1} -!3 = !{!"llvm.loop.vectorize.predicate.enable", i1 false} -!4 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!3 = !{!"llvm.loop.vectorize.predicate.disable"} +!4 = !{!"llvm.loop.vectorize.predicate.enable"} diff --git a/llvm/test/Transforms/LoopVectorize/VPlan/constant-fold.ll b/llvm/test/Transforms/LoopVectorize/VPlan/constant-fold.ll index 4ec0ec66d4321..cb00f39754036 100644 --- a/llvm/test/Transforms/LoopVectorize/VPlan/constant-fold.ll +++ b/llvm/test/Transforms/LoopVectorize/VPlan/constant-fold.ll @@ -319,4 +319,4 @@ exit: !1 = distinct !{!1, !2, !3, !4} !2 = !{!"llvm.loop.vectorize.width", i32 4} !3 = !{!"llvm.loop.vectorize.enable"} -!4 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!4 = !{!"llvm.loop.vectorize.predicate.enable"} diff --git a/llvm/test/Transforms/LoopVectorize/X86/induction-costs.ll b/llvm/test/Transforms/LoopVectorize/X86/induction-costs.ll index 815d13351d15d..92b95f2256ebf 100644 --- a/llvm/test/Transforms/LoopVectorize/X86/induction-costs.ll +++ b/llvm/test/Transforms/LoopVectorize/X86/induction-costs.ll @@ -643,7 +643,7 @@ exit: !1 = distinct !{!1, !2, !3, !4} !2 = !{!"llvm.loop.vectorize.width", i32 4} !3 = !{!"llvm.loop.vectorize.enable"} -!4 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!4 = !{!"llvm.loop.vectorize.predicate.enable"} define void @wide_iv_trunc_reuse(ptr %dst) { ; CHECK-LABEL: define void @wide_iv_trunc_reuse( diff --git a/llvm/test/Transforms/LoopVectorize/X86/tail_folding_and_assume_safety.ll b/llvm/test/Transforms/LoopVectorize/X86/tail_folding_and_assume_safety.ll index a1def726e10ed..ca8b382556009 100644 --- a/llvm/test/Transforms/LoopVectorize/X86/tail_folding_and_assume_safety.ll +++ b/llvm/test/Transforms/LoopVectorize/X86/tail_folding_and_assume_safety.ll @@ -146,9 +146,9 @@ attributes #0 = { "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "use-soft-float !7 = !{!"llvm.loop.vectorize.enable"} !8 = distinct !{!8, !9} -!9 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!9 = !{!"llvm.loop.vectorize.predicate.enable"} !10 = distinct !{} !11 = distinct !{!11, !12, !13} !12 = !{!"llvm.loop.parallel_accesses", !10} -!13 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!13 = !{!"llvm.loop.vectorize.predicate.enable"} diff --git a/llvm/test/Transforms/LoopVectorize/X86/tail_loop_folding.ll b/llvm/test/Transforms/LoopVectorize/X86/tail_loop_folding.ll index e5b88dd5219db..e42b16098776c 100644 --- a/llvm/test/Transforms/LoopVectorize/X86/tail_loop_folding.ll +++ b/llvm/test/Transforms/LoopVectorize/X86/tail_loop_folding.ll @@ -171,8 +171,8 @@ for.cond.cleanup: attributes #0 = { optsize "target-cpu"="core-avx2" "target-features"="+avx,+avx2" } !6 = distinct !{!6, !7, !8} -!7 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!7 = !{!"llvm.loop.vectorize.predicate.enable"} !8 = !{!"llvm.loop.vectorize.enable"} !10 = distinct !{!10, !11} -!11 = !{!"llvm.loop.vectorize.predicate.enable", i1 false} +!11 = !{!"llvm.loop.vectorize.predicate.disable"} diff --git a/llvm/test/Transforms/LoopVectorize/no-fold-tail-by-masking-iv-external-uses.ll b/llvm/test/Transforms/LoopVectorize/no-fold-tail-by-masking-iv-external-uses.ll index 6a80b02aaf50e..7e6247033a875 100644 --- a/llvm/test/Transforms/LoopVectorize/no-fold-tail-by-masking-iv-external-uses.ll +++ b/llvm/test/Transforms/LoopVectorize/no-fold-tail-by-masking-iv-external-uses.ll @@ -128,7 +128,7 @@ done: !0 = distinct !{!0, !1, !2, !3} !1 = !{!"llvm.loop.unroll.disable"} -!2 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!2 = !{!"llvm.loop.vectorize.predicate.enable"} !3 = !{!"llvm.loop.vectorize.enable"} ;. ; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]], [[META3:![0-9]+]]} diff --git a/llvm/test/Transforms/LoopVectorize/reduction-inloop-uf4.ll b/llvm/test/Transforms/LoopVectorize/reduction-inloop-uf4.ll index 4751570432927..2737e3accf37a 100644 --- a/llvm/test/Transforms/LoopVectorize/reduction-inloop-uf4.ll +++ b/llvm/test/Transforms/LoopVectorize/reduction-inloop-uf4.ll @@ -611,5 +611,5 @@ for.end: } !6 = distinct !{!6, !7, !8} -!7 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!7 = !{!"llvm.loop.vectorize.predicate.enable"} !8 = !{!"llvm.loop.vectorize.enable"} diff --git a/llvm/test/Transforms/LoopVectorize/reduction-inloop.ll b/llvm/test/Transforms/LoopVectorize/reduction-inloop.ll index 73ce57b156952..abf0100a2440a 100644 --- a/llvm/test/Transforms/LoopVectorize/reduction-inloop.ll +++ b/llvm/test/Transforms/LoopVectorize/reduction-inloop.ll @@ -3138,5 +3138,5 @@ for.exit: !6 = distinct !{!6, !7, !8} -!7 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!7 = !{!"llvm.loop.vectorize.predicate.enable"} !8 = !{!"llvm.loop.vectorize.enable"} diff --git a/llvm/test/Transforms/LoopVectorize/use-scalar-epilogue-if-tp-fails.ll b/llvm/test/Transforms/LoopVectorize/use-scalar-epilogue-if-tp-fails.ll index 5d65362df3cc2..6135464eaca14 100644 --- a/llvm/test/Transforms/LoopVectorize/use-scalar-epilogue-if-tp-fails.ll +++ b/llvm/test/Transforms/LoopVectorize/use-scalar-epilogue-if-tp-fails.ll @@ -244,5 +244,5 @@ end: } !1 = distinct !{!1, !2, !3} -!2 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!2 = !{!"llvm.loop.vectorize.predicate.enable"} !3 = !{!"llvm.loop.vectorize.enable"} diff --git a/llvm/test/Transforms/LoopVectorize/vector-loop-backedge-elimination-predicated-early-exit.ll b/llvm/test/Transforms/LoopVectorize/vector-loop-backedge-elimination-predicated-early-exit.ll index ce0da2efcab20..be0a9c5b7e7d7 100644 --- a/llvm/test/Transforms/LoopVectorize/vector-loop-backedge-elimination-predicated-early-exit.ll +++ b/llvm/test/Transforms/LoopVectorize/vector-loop-backedge-elimination-predicated-early-exit.ll @@ -50,5 +50,5 @@ exit: !0 = distinct !{!0, !1, !2, !3} !1 = !{!"llvm.loop.mustprogress"} -!2 = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +!2 = !{!"llvm.loop.vectorize.predicate.enable"} !3 = !{!"llvm.loop.vectorize.enable"} diff --git a/llvm/test/Verifier/llvm.loop.vectorize.predicate.ll b/llvm/test/Verifier/llvm.loop.vectorize.predicate.ll new file mode 100644 index 0000000000000..943efa88c22ad --- /dev/null +++ b/llvm/test/Verifier/llvm.loop.vectorize.predicate.ll @@ -0,0 +1,41 @@ +; Test "llvm.loop.vectorize.predicate.enable" / +; "llvm.loop.vectorize.predicate.disable" single-operand validation. + +; DEFINE: %{VERIFY} = llvm-as -disable-output %t 2>&1 + +define void @test() { +entry: + br label %body +body: + br i1 0, label %body, label %exit, !llvm.loop !0 +exit: + ret void +} +!0 = distinct !{!0, !1} + +; BAD: Expecting only the metadata name + +; Single-operand enable. +; RUN: cat %s > %t +; RUN: echo '!1 = !{!"llvm.loop.vectorize.predicate.enable"}' >> %t +; RUN: %{VERIFY} + +; Single-operand disable. +; RUN: cat %s > %t +; RUN: echo '!1 = !{!"llvm.loop.vectorize.predicate.disable"}' >> %t +; RUN: %{VERIFY} + +; Two-operand enable with boolean false (legacy form, now rejected). +; RUN: cat %s > %t +; RUN: echo '!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 0}' >> %t +; RUN: not %{VERIFY} | FileCheck %s -check-prefix=BAD + +; Two-operand enable with boolean true (legacy form, now rejected). +; RUN: cat %s > %t +; RUN: echo '!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 1}' >> %t +; RUN: not %{VERIFY} | FileCheck %s -check-prefix=BAD + +; Two-operand disable (rejected). +; RUN: cat %s > %t +; RUN: echo '!1 = !{!"llvm.loop.vectorize.predicate.disable", i1 0}' >> %t +; RUN: not %{VERIFY} | FileCheck %s -check-prefix=BAD diff --git a/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp b/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp index 7f80b5be28b0b..1bf3400614cf5 100644 --- a/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp +++ b/mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp @@ -289,7 +289,8 @@ FailureOr<LoopVectorizeAttr> LoopMetadataConversion::convertVectorizeAttr() { "llvm.loop.vectorize.enable", "llvm.loop.vectorize.disable", /*negated=*/true); FailureOr<BoolAttr> predicateEnable = - lookupBoolNode("llvm.loop.vectorize.predicate.enable"); + lookupBooleanUnitNode("llvm.loop.vectorize.predicate.enable", + "llvm.loop.vectorize.predicate.disable"); FailureOr<BoolAttr> scalableEnable = lookupBoolNode("llvm.loop.vectorize.scalable.enable"); FailureOr<IntegerAttr> width = lookupIntNode("llvm.loop.vectorize.width"); diff --git a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp index 7420142957d4c..7641810251cf7 100644 --- a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp @@ -31,6 +31,8 @@ struct LoopAnnotationConversion { void addUnitNode(StringRef name, BoolAttr attr); void addI32NodeWithVal(StringRef name, uint32_t val); void convertBoolNode(StringRef name, BoolAttr attr, bool negated = false); + void convertBooleanUnitNode(StringRef enableName, StringRef disableName, + BoolAttr attr, bool negated = false); void convertI32Node(StringRef name, IntegerAttr attr); void convertFollowupNode(StringRef name, LoopAnnotationAttr attr); void convertLocation(FusedLoc attr); @@ -83,6 +85,17 @@ void LoopAnnotationConversion::convertBoolNode(StringRef name, BoolAttr attr, llvm::ConstantAsMetadata::get(cstValue)})); } +/// Emits the single-operand node of an enable/disable pair. As in +/// convertBoolNode, \p negated ^ the attribute value is the enable bit. +void LoopAnnotationConversion::convertBooleanUnitNode(StringRef enableName, + StringRef disableName, + BoolAttr attr, + bool negated) { + if (!attr) + return; + addUnitNode((negated ^ attr.getValue()) ? enableName : disableName); +} + void LoopAnnotationConversion::convertI32Node(StringRef name, IntegerAttr attr) { if (!attr) @@ -103,14 +116,12 @@ void LoopAnnotationConversion::convertFollowupNode(StringRef name, } void LoopAnnotationConversion::convertLoopOptions(LoopVectorizeAttr options) { - if (auto disable = options.getDisable()) { - if (disable.getValue()) - addUnitNode("llvm.loop.vectorize.disable"); - else - addUnitNode("llvm.loop.vectorize.enable"); - } - convertBoolNode("llvm.loop.vectorize.predicate.enable", - options.getPredicateEnable()); + convertBooleanUnitNode("llvm.loop.vectorize.enable", + "llvm.loop.vectorize.disable", options.getDisable(), + /*negated=*/true); + convertBooleanUnitNode("llvm.loop.vectorize.predicate.enable", + "llvm.loop.vectorize.predicate.disable", + options.getPredicateEnable()); convertBoolNode("llvm.loop.vectorize.scalable.enable", options.getScalableEnable()); convertI32Node("llvm.loop.vectorize.width", options.getWidth()); @@ -167,12 +178,9 @@ void LoopAnnotationConversion::convertLoopOptions(LoopLICMAttr options) { } void LoopAnnotationConversion::convertLoopOptions(LoopDistributeAttr options) { - if (auto disable = options.getDisable()) { - if (disable.getValue()) - addUnitNode("llvm.loop.distribute.disable"); - else - addUnitNode("llvm.loop.distribute.enable"); - } + convertBooleanUnitNode("llvm.loop.distribute.enable", + "llvm.loop.distribute.disable", options.getDisable(), + /*negated=*/true); 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 d64a96c1b1422..7b4a6d7fa5263 100644 --- a/mlir/test/Target/LLVMIR/Import/metadata-loop.ll +++ b/mlir/test/Target/LLVMIR/Import/metadata-loop.ll @@ -87,7 +87,7 @@ end: !1 = distinct !{!1, !2, !3, !4, !5, !6, !7, !8} !2 = !{!"llvm.loop.vectorize.enable"} -!3 = !{!"llvm.loop.vectorize.predicate.enable", i1 1} +!3 = !{!"llvm.loop.vectorize.predicate.enable"} !4 = !{!"llvm.loop.vectorize.scalable.enable", i1 0} !5 = !{!"llvm.loop.vectorize.width", i32 16} !6 = !{!"llvm.loop.vectorize.followup_vectorized", !9} diff --git a/mlir/test/Target/LLVMIR/loop-metadata.mlir b/mlir/test/Target/LLVMIR/loop-metadata.mlir index ada830e103a2c..50293246d34d5 100644 --- a/mlir/test/Target/LLVMIR/loop-metadata.mlir +++ b/mlir/test/Target/LLVMIR/loop-metadata.mlir @@ -56,7 +56,7 @@ llvm.func @vectorizeOptions() { // 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]+}}, !{{[0-9]+}}, !{{[0-9]+}}} // CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.vectorize.enable"} -// CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.vectorize.predicate.enable", i1 true} +// CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.vectorize.predicate.enable"} // CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.vectorize.scalable.enable", i1 false} // CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.vectorize.width", i32 16} // CHECK-DAG: !{{[0-9]+}} = !{!"llvm.loop.vectorize.followup_vectorized", ![[FOLLOWUP]]} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
