Agreed about preferring loop.vectorize to loop.vectorizer.  Thanks for
the reviews.  Attached are the updated patches.  Eli, can you submit
these?

Thanks,
Mark

On Tue, Jun 24, 2014 at 6:40 PM, Tyler Nowicki <[email protected]> wrote:
> Hi Mark,
>
> I also have a weak preference for the llvm.loop.unroll/vectorize option 
> because I would like to add metadata for interleaving and I think 
> interleave.enable would look better than interleaver.enable. Otherwise LGTM!
>
> Tyler
>
> On Jun 24, 2014, at 4:28 PM, Hal Finkel <[email protected]> wrote:
>
>> ----- Original Message -----
>>> From: "Mark Heffernan" <[email protected]>
>>> To: "Hal Finkel" <[email protected]>
>>> Cc: [email protected], "cfe-commits" <[email protected]>, 
>>> "Pekka Jääskeläinen"
>>> <[email protected]>
>>> Sent: Tuesday, June 24, 2014 4:18:30 PM
>>> Subject: Re: [PATCH] Change loop unroll and vectorizer metadata prefix to 
>>> 'llvm.loop.'
>>>
>>> The attached patch includes a note in ReleaseNotes.rst and code to
>>> autoupgrade llvm.vectorizer.* metadata strings to
>>> llvm.loop.vectorizer.* when reading assembly and bitcode.  PTAL.
>>
>> Okay, thanks. That's better. However, I just noticed that the proposed 
>> mapping:
>>
>>> llvm.vectorizer.* => llvm.loop.vectorizer.*
>>> llvm.loopunroll.* => llvm.loop.unroll.*
>>
>> is not grammatically consistent. I think that we should have 
>> ("llvm.loop.vectorize" and "llvm.loop.unroll") or ("llvm.loop.vectorizer" 
>> and "llvm.loop.unroller"). I have a weak preference for the first pair, but 
>> I care more about consistency than the choice.
>>
>> -Hal
>>
>>>
>>> Thanks!
>>> Mark
>>>
>>> On Tue, Jun 24, 2014 at 9:53 AM, Hal Finkel <[email protected]> wrote:
>>>> ----- Original Message -----
>>>>> From: "Mark Heffernan" <[email protected]>
>>>>> To: "Hal Finkel" <[email protected]>
>>>>> Cc: [email protected], "cfe-commits"
>>>>> <[email protected]>, "Pekka Jääskeläinen"
>>>>> <[email protected]>
>>>>> Sent: Tuesday, June 24, 2014 11:18:33 AM
>>>>> Subject: Re: [PATCH] Change loop unroll and vectorizer metadata
>>>>> prefix to 'llvm.loop.'
>>>>>
>>>>> Thanks for the comments.  I'll add something to the release notes.
>>>>>
>>>>> On Tue, Jun 24, 2014 at 3:52 AM, Hal Finkel <[email protected]>
>>>>> wrote:
>>>>>> Moreover, for metadata that was supported by the 3.4 release,
>>>>>> autoupgrade support should be added. Please do this before you
>>>>>> commit.
>>>>>
>>>>> By autoupgrade do you mean be permissive about what is accepted?
>>>>> That
>>>>> is, accept llvm.vectorizer.* and llvm.loop.vectorizer.* but only
>>>>> emit
>>>>> the llvm.loop form from the FE.  Or do you mean try to rename the
>>>>> metadata as soon as it parsed?  I can see how to do the first case
>>>>> (be
>>>>> permissive) easily, but for the second (rename metadata) do you
>>>>> have
>>>>> any suggestions for the best place to cut in (I'm fairly new to
>>>>> the
>>>>> code base)?
>>>>
>>>> No, I mean the second. I believe that most of the current logic for
>>>> this is in lib/IR/AutoUpgrade.cpp
>>>>
>>>> -Hal
>>>>
>>>>>
>>>>> Thanks!
>>>>> Mark
>>>>>
>>>>>>
>>>>>> -Hal
>>>>>>
>>>>>>>
>>>>>>> On Tue, Jun 24, 2014 at 12:30 AM, Mark Heffernan
>>>>>>> <[email protected]>
>>>>>>> wrote:
>>>>>>>> These patches rename the loop unrolling and loop vectorizer
>>>>>>>> metadata
>>>>>>>> such that they have a common 'llvm.loop.' prefix.  Metadata
>>>>>>>> name
>>>>>>>> changes:
>>>>>>>>
>>>>>>>> llvm.vectorizer.* => llvm.loop.vectorizer.*
>>>>>>>> llvm.loopunroll.* => llvm.loop.unroll.*
>>>>>>>>
>>>>>>>> This was a suggestion from an earlier review
>>>>>>>> (http://reviews.llvm.org/D4090) which added the loop
>>>>>>>> unrolling
>>>>>>>> metadata.  Two patches are attached.  One for front-end and
>>>>>>>> one
>>>>>>>> for
>>>>>>>> optimizer.
>>>>>>>>
>>>>>>>> Mark
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> --PJ
>>>>>>> _______________________________________________
>>>>>>> cfe-commits mailing list
>>>>>>> [email protected]
>>>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> Hal Finkel
>>>>>> Assistant Computational Scientist
>>>>>> Leadership Computing Facility
>>>>>> Argonne National Laboratory
>>>>>
>>>>
>>>> --
>>>> Hal Finkel
>>>> Assistant Computational Scientist
>>>> Leadership Computing Facility
>>>> Argonne National Laboratory
>>>
>>
>> --
>> Hal Finkel
>> Assistant Computational Scientist
>> Leadership Computing Facility
>> Argonne National Laboratory
>>
>> _______________________________________________
>> llvm-commits mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
Index: lib/CodeGen/CGLoopInfo.cpp
===================================================================
--- lib/CodeGen/CGLoopInfo.cpp	(revision 211528)
+++ lib/CodeGen/CGLoopInfo.cpp	(working copy)
@@ -31,7 +31,7 @@
 
   // Setting vectorizer.width
   if (Attrs.VectorizerWidth > 0) {
-    Value *Vals[] = { MDString::get(Ctx, "llvm.vectorizer.width"),
+    Value *Vals[] = { MDString::get(Ctx, "llvm.loop.vectorize.width"),
                       ConstantInt::get(Type::getInt32Ty(Ctx),
                                        Attrs.VectorizerWidth) };
     Args.push_back(MDNode::get(Ctx, Vals));
@@ -39,7 +39,7 @@
 
   // Setting vectorizer.unroll
   if (Attrs.VectorizerUnroll > 0) {
-    Value *Vals[] = { MDString::get(Ctx, "llvm.vectorizer.unroll"),
+    Value *Vals[] = { MDString::get(Ctx, "llvm.loop.vectorize.unroll"),
                       ConstantInt::get(Type::getInt32Ty(Ctx),
                                        Attrs.VectorizerUnroll) };
     Args.push_back(MDNode::get(Ctx, Vals));
@@ -47,7 +47,7 @@
 
   // Setting vectorizer.enable
   if (Attrs.VectorizerEnable != LoopAttributes::VecUnspecified) {
-    Value *Vals[] = { MDString::get(Ctx, "llvm.vectorizer.enable"),
+    Value *Vals[] = { MDString::get(Ctx, "llvm.loop.vectorize.enable"),
                       ConstantInt::get(Type::getInt1Ty(Ctx),
                                        (Attrs.VectorizerEnable ==
                                         LoopAttributes::VecEnable)) };
Index: lib/CodeGen/CGLoopInfo.h
===================================================================
--- lib/CodeGen/CGLoopInfo.h	(revision 211528)
+++ lib/CodeGen/CGLoopInfo.h	(working copy)
@@ -37,16 +37,16 @@
   /// \brief Generate llvm.loop.parallel metadata for loads and stores.
   bool IsParallel;
 
-  /// \brief Values of llvm.vectorizer.enable metadata.
+  /// \brief Values of llvm.loop.vectorize.enable metadata.
   enum LVEnableState { VecUnspecified, VecEnable, VecDisable };
 
-  /// \brief llvm.vectorizer.enable
+  /// \brief llvm.loop.vectorize.enable
   LVEnableState VectorizerEnable;
 
-  /// \brief llvm.vectorizer.width
+  /// \brief llvm.loop.vectorize.width
   unsigned VectorizerWidth;
 
-  /// \brief llvm.vectorizer.unroll
+  /// \brief llvm.loop.vectorize.unroll
   unsigned VectorizerUnroll;
 };
 
Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp	(revision 211528)
+++ lib/CodeGen/CGStmt.cpp	(working copy)
@@ -531,7 +531,7 @@
   if (Attrs.empty())
     return;
 
-  // Add vectorize hints to the metadata on the conditional branch.
+  // Add vectorize and unroll hints to the metadata on the conditional branch.
   SmallVector<llvm::Value *, 2> Metadata(1);
   for (const auto *Attr : Attrs) {
     const LoopHintAttr *LH = dyn_cast<LoopHintAttr>(Attr);
@@ -547,17 +547,17 @@
     switch (Option) {
     case LoopHintAttr::Vectorize:
     case LoopHintAttr::VectorizeWidth:
-      MetadataName = "llvm.vectorizer.width";
+      MetadataName = "llvm.loop.vectorize.width";
       break;
     case LoopHintAttr::Interleave:
     case LoopHintAttr::InterleaveCount:
-      MetadataName = "llvm.vectorizer.unroll";
+      MetadataName = "llvm.loop.vectorize.unroll";
       break;
     case LoopHintAttr::Unroll:
-      MetadataName = "llvm.loopunroll.enable";
+      MetadataName = "llvm.loop.unroll.enable";
       break;
     case LoopHintAttr::UnrollCount:
-      MetadataName = "llvm.loopunroll.count";
+      MetadataName = "llvm.loop.unroll.count";
       break;
     }
 
@@ -569,7 +569,7 @@
       if (ValueInt == 1) {
         // FIXME: In the future I will modifiy the behavior of the metadata
         // so we can enable/disable vectorization and interleaving separately.
-        Name = llvm::MDString::get(Context, "llvm.vectorizer.enable");
+        Name = llvm::MDString::get(Context, "llvm.loop.vectorize.enable");
         Value = Builder.getTrue();
         break;
       }
Index: test/CodeGen/pragma-loop.cpp
===================================================================
--- test/CodeGen/pragma-loop.cpp	(revision 211528)
+++ test/CodeGen/pragma-loop.cpp	(working copy)
@@ -109,21 +109,21 @@
 }
 
 // CHECK: ![[LOOP_1]] = metadata !{metadata ![[LOOP_1]], metadata ![[UNROLLENABLE_1:.*]], metadata ![[WIDTH_4:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[INTENABLE_1:.*]]}
-// CHECK: ![[UNROLLENABLE_1]] = metadata !{metadata !"llvm.loopunroll.enable", i1 true}
-// CHECK: ![[WIDTH_4]] = metadata !{metadata !"llvm.vectorizer.width", i32 4}
-// CHECK: ![[INTERLEAVE_4]] = metadata !{metadata !"llvm.vectorizer.unroll", i32 4}
-// CHECK: ![[INTENABLE_1]] = metadata !{metadata !"llvm.vectorizer.enable", i1 true}
+// CHECK: ![[UNROLLENABLE_1]] = metadata !{metadata !"llvm.loop.unroll.enable", i1 true}
+// CHECK: ![[WIDTH_4]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 4}
+// CHECK: ![[INTERLEAVE_4]] = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 4}
+// CHECK: ![[INTENABLE_1]] = metadata !{metadata !"llvm.loop.vectorize.enable", i1 true}
 // CHECK: ![[LOOP_2]] = metadata !{metadata ![[LOOP_2:.*]], metadata ![[UNROLLENABLE_0:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[WIDTH_8:.*]]}
-// CHECK: ![[UNROLLENABLE_0]] = metadata !{metadata !"llvm.loopunroll.enable", i1 false}
-// CHECK: ![[WIDTH_8]] = metadata !{metadata !"llvm.vectorizer.width", i32 8}
+// CHECK: ![[UNROLLENABLE_0]] = metadata !{metadata !"llvm.loop.unroll.enable", i1 false}
+// CHECK: ![[WIDTH_8]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 8}
 // CHECK: ![[LOOP_3]] = metadata !{metadata ![[LOOP_3]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[ENABLE_1:.*]]}
-// CHECK: ![[UNROLL_8]] = metadata !{metadata !"llvm.loopunroll.count", i32 8}
+// CHECK: ![[UNROLL_8]] = metadata !{metadata !"llvm.loop.unroll.count", i32 8}
 // CHECK: ![[LOOP_4]] = metadata !{metadata ![[LOOP_4]], metadata ![[INTERLEAVE_2:.*]], metadata ![[WIDTH_2:.*]]}
-// CHECK: ![[INTERLEAVE_2]] = metadata !{metadata !"llvm.vectorizer.unroll", i32 2}
-// CHECK: ![[WIDTH_2]] = metadata !{metadata !"llvm.vectorizer.width", i32 2}
+// CHECK: ![[INTERLEAVE_2]] = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 2}
+// CHECK: ![[WIDTH_2]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 2}
 // CHECK: ![[LOOP_5]] = metadata !{metadata ![[LOOP_5]], metadata ![[UNROLLENABLE_0:.*]], metadata ![[WIDTH_1:.*]]}
-// CHECK: ![[WIDTH_1]] = metadata !{metadata !"llvm.vectorizer.width", i32 1}
+// CHECK: ![[WIDTH_1]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
 // CHECK: ![[LOOP_6]] = metadata !{metadata ![[LOOP_6]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_2:.*]], metadata ![[WIDTH_2:.*]]}
 // CHECK: ![[LOOP_7]] = metadata !{metadata ![[LOOP_7]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_8:.*]], metadata ![[WIDTH_8:.*]]}
-// CHECK: ![[INTERLEAVE_8]] = metadata !{metadata !"llvm.vectorizer.unroll", i32 8}
+// CHECK: ![[INTERLEAVE_8]] = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 8}
 // CHECK: ![[LOOP_8]] = metadata !{metadata ![[LOOP_8]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_2:.*]], metadata ![[WIDTH_2:.*]]}
Index: test/OpenMP/simd_metadata.c
===================================================================
--- test/OpenMP/simd_metadata.c	(revision 211528)
+++ test/OpenMP/simd_metadata.c	(working copy)
@@ -40,8 +40,8 @@
 
 // Metadata for h1:
 // CHECK: [[LOOP_H1_HEADER:![0-9]+]] = metadata !{metadata [[LOOP_H1_HEADER]], metadata [[LOOP_WIDTH_16:![0-9]+]], metadata [[LOOP_VEC_ENABLE:![0-9]+]]}
-// CHECK: [[LOOP_WIDTH_16]] = metadata !{metadata !"llvm.vectorizer.width", i32 16}
-// CHECK: [[LOOP_VEC_ENABLE]] = metadata !{metadata !"llvm.vectorizer.enable", i1 true}
+// CHECK: [[LOOP_WIDTH_16]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 16}
+// CHECK: [[LOOP_VEC_ENABLE]] = metadata !{metadata !"llvm.loop.vectorize.enable", i1 true}
 //
 // Metadata for h2:
 // CHECK: [[LOOP_H2_HEADER]] = metadata !{metadata [[LOOP_H2_HEADER]], metadata [[LOOP_VEC_ENABLE]]}
@@ -49,4 +49,3 @@
 // Metadata for h3:
 // CHECK: [[LOOP_H3_HEADER:![0-9]+]] = metadata !{metadata [[LOOP_H3_HEADER]], metadata [[LOOP_VEC_ENABLE]]}
 //
-
Index: docs/LangRef.rst
===================================================================
--- docs/LangRef.rst	(revision 211528)
+++ docs/LangRef.rst	(working copy)
@@ -2804,7 +2804,7 @@
 
 The loop identifier metadata can be used to specify additional per-loop
 metadata. Any operands after the first operand can be treated as user-defined
-metadata. For example the ``llvm.vectorizer.unroll`` metadata is understood
+metadata. For example the ``llvm.loop.vectorize.unroll`` metadata is understood
 by the loop vectorizer to indicate how many times to unroll the loop:
 
 .. code-block:: llvm
@@ -2812,7 +2812,7 @@
       br i1 %exitcond, label %._crit_edge, label %.lr.ph, !llvm.loop !0
     ...
     !0 = metadata !{ metadata !0, metadata !1 }
-    !1 = metadata !{ metadata !"llvm.vectorizer.unroll", i32 2 }
+    !1 = metadata !{ metadata !"llvm.loop.vectorize.unroll", i32 2 }
 
 '``llvm.mem``'
 ^^^^^^^^^^^^^^^
@@ -2897,36 +2897,36 @@
    !1 = metadata !{ metadata !1 } ; an identifier for the inner loop
    !2 = metadata !{ metadata !2 } ; an identifier for the outer loop
 
-'``llvm.vectorizer``'
-^^^^^^^^^^^^^^^^^^^^^
+'``llvm.loop.vectorize``'
+^^^^^^^^^^^^^^^^^^^^^^^^^
 
-Metadata prefixed with ``llvm.vectorizer`` is used to control per-loop
+Metadata prefixed with ``llvm.loop.vectorize`` is used to control per-loop
 vectorization parameters such as vectorization factor and unroll factor.
 
-``llvm.vectorizer`` metadata should be used in conjunction with ``llvm.loop``
-loop identification metadata.
+``llvm.loop.vectorize`` metadata should be used in conjunction with
+``llvm.loop`` loop identification metadata.
 
-'``llvm.vectorizer.unroll``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+'``llvm.loop.vectorize.unroll``' Metadata
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 This metadata instructs the loop vectorizer to unroll the specified
 loop exactly ``N`` times.
 
-The first operand is the string ``llvm.vectorizer.unroll`` and the second
+The first operand is the string ``llvm.loop.vectorize.unroll`` and the second
 operand is an integer specifying the unroll factor. For example:
 
 .. code-block:: llvm
 
-   !0 = metadata !{ metadata !"llvm.vectorizer.unroll", i32 4 }
+   !0 = metadata !{ metadata !"llvm.loop.vectorize.unroll", i32 4 }
 
-Note that setting ``llvm.vectorizer.unroll`` to 1 disables unrolling of the
-loop.
+Note that setting ``llvm.loop.vectorize.unroll`` to 1 disables
+unrolling of the loop.
 
-If ``llvm.vectorizer.unroll`` is set to 0 then the amount of unrolling will be
-determined automatically.
+If ``llvm.loop.vectorize.unroll`` is set to 0 then the amount of
+unrolling will be determined automatically.
 
-'``llvm.vectorizer.width``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+'``llvm.loop.vectorize.width``' Metadata
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 This metadata sets the target width of the vectorizer to ``N``. Without
 this metadata, the vectorizer will choose a width automatically.
@@ -2933,18 +2933,18 @@
 Regardless of this metadata, the vectorizer will only vectorize loops if
 it believes it is valid to do so.
 
-The first operand is the string ``llvm.vectorizer.width`` and the second
-operand is an integer specifying the width. For example:
+The first operand is the string ``llvm.loop.vectorize.width`` and the
+second operand is an integer specifying the width. For example:
 
 .. code-block:: llvm
 
-   !0 = metadata !{ metadata !"llvm.vectorizer.width", i32 4 }
+   !0 = metadata !{ metadata !"llvm.loop.vectorize.width", i32 4 }
 
-Note that setting ``llvm.vectorizer.width`` to 1 disables vectorization of the
-loop.
+Note that setting ``llvm.loop.vectorize.width`` to 1 disables
+vectorization of the loop.
 
-If ``llvm.vectorizer.width`` is set to 0 then the width will be determined
-automatically.
+If ``llvm.loop.vectorize.width`` is set to 0 then the width will be
+determined automatically.
 
 Module Flags Metadata
 =====================
Index: docs/ReleaseNotes.rst
===================================================================
--- docs/ReleaseNotes.rst	(revision 211528)
+++ docs/ReleaseNotes.rst	(working copy)
@@ -55,6 +55,9 @@
 * LLVM now always uses cfi directives for producing most stack
   unwinding information.
 
+* The prefix for loop vectorizer hint metadata has been changed from
+  ``llvm.vectorizer`` to ``llvm.loop.vectorize``.
+
 .. NOTE
    For small 1-3 sentence descriptions, just add an entry at the end of
    this list. If your description won't fit comfortably in one bullet
Index: include/llvm/IR/AutoUpgrade.h
===================================================================
--- include/llvm/IR/AutoUpgrade.h	(revision 211528)
+++ include/llvm/IR/AutoUpgrade.h	(working copy)
@@ -14,6 +14,8 @@
 #ifndef LLVM_IR_AUTOUPGRADE_H
 #define LLVM_IR_AUTOUPGRADE_H
 
+#include <string>
+
 namespace llvm {
   class CallInst;
   class Constant;
@@ -61,6 +63,9 @@
   /// Check the debug info version number, if it is out-dated, drop the debug
   /// info. Return true if module is modified.
   bool UpgradeDebugInfo(Module &M);
+
+  /// Upgrade a metadata string constant in place.
+  void UpgradeMDStringConstant(std::string &String);
 } // End llvm namespace
 
 #endif
Index: lib/AsmParser/LLParser.cpp
===================================================================
--- lib/AsmParser/LLParser.cpp	(revision 211528)
+++ lib/AsmParser/LLParser.cpp	(working copy)
@@ -518,6 +518,7 @@
 bool LLParser::ParseMDString(MDString *&Result) {
   std::string Str;
   if (ParseStringConstant(Str)) return true;
+  llvm::UpgradeMDStringConstant(Str);
   Result = MDString::get(Context, Str);
   return false;
 }
Index: lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- lib/Bitcode/Reader/BitcodeReader.cpp	(revision 211528)
+++ lib/Bitcode/Reader/BitcodeReader.cpp	(working copy)
@@ -1064,7 +1064,8 @@
       break;
     }
     case bitc::METADATA_STRING: {
-      SmallString<8> String(Record.begin(), Record.end());
+      std::string String(Record.begin(), Record.end());
+      llvm::UpgradeMDStringConstant(String);
       Value *V = MDString::get(Context, String);
       MDValueList.AssignValue(V, NextMDValueNo++);
       break;
Index: lib/IR/AutoUpgrade.cpp
===================================================================
--- lib/IR/AutoUpgrade.cpp	(revision 211528)
+++ lib/IR/AutoUpgrade.cpp	(working copy)
@@ -577,3 +577,10 @@
   }
   return RetCode;
 }
+
+void llvm::UpgradeMDStringConstant(std::string &String) {
+  const std::string OldPrefix = "llvm.vectorizer.";
+  if (String.find(OldPrefix) == 0) {
+        String.replace(0, OldPrefix.size(), "llvm.loop.vectorize.");
+  }
+}
Index: lib/Transforms/Scalar/LoopUnrollPass.cpp
===================================================================
--- lib/Transforms/Scalar/LoopUnrollPass.cpp	(revision 211528)
+++ lib/Transforms/Scalar/LoopUnrollPass.cpp	(working copy)
@@ -220,7 +220,7 @@
 }
 
 // Returns the value associated with the given metadata node name (for
-// example, "llvm.loopunroll.count").  If no such named metadata node
+// example, "llvm.loop.unroll.count").  If no such named metadata node
 // exists, then nullptr is returned.
 static const ConstantInt *GetUnrollMetadataValue(const Loop *L,
                                                  StringRef Name) {
@@ -250,17 +250,15 @@
 // Returns true if the loop has an unroll(enable) pragma.
 static bool HasUnrollEnablePragma(const Loop *L) {
   const ConstantInt *EnableValue =
-      GetUnrollMetadataValue(L, "llvm.loopunroll.enable");
+      GetUnrollMetadataValue(L, "llvm.loop.unroll.enable");
   return (EnableValue && EnableValue->getZExtValue());
-  return false;
 }
 
 // Returns true if the loop has an unroll(disable) pragma.
 static bool HasUnrollDisablePragma(const Loop *L) {
   const ConstantInt *EnableValue =
-      GetUnrollMetadataValue(L, "llvm.loopunroll.enable");
+      GetUnrollMetadataValue(L, "llvm.loop.unroll.enable");
   return (EnableValue && !EnableValue->getZExtValue());
-  return false;
 }
 
 // If loop has an unroll_count pragma return the (necessarily
@@ -267,7 +265,7 @@
 // positive) value from the pragma.  Otherwise return 0.
 static unsigned UnrollCountPragmaValue(const Loop *L) {
   const ConstantInt *CountValue =
-      GetUnrollMetadataValue(L, "llvm.loopunroll.count");
+      GetUnrollMetadataValue(L, "llvm.loop.unroll.count");
   if (CountValue) {
     unsigned Count = CountValue->getZExtValue();
     assert(Count >= 1 && "Unroll count must be positive.");
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp	(revision 211528)
+++ lib/Transforms/Vectorize/LoopVectorize.cpp	(working copy)
@@ -906,7 +906,7 @@
   }
 
   /// Return the loop vectorizer metadata prefix.
-  static StringRef Prefix() { return "llvm.vectorizer."; }
+  static StringRef Prefix() { return "llvm.loop.vectorize."; }
 
   MDNode *createHint(LLVMContext &Context, StringRef Name, unsigned V) const {
     SmallVector<Value*, 2> Vals;
@@ -5859,4 +5859,3 @@
   Constant *C = ConstantInt::get(ITy, StartIdx, Negate);
   return Builder.CreateAdd(Val, C, "induction");
 }
-
Index: test/Assembler/upgrade-loop-metadata.ll
===================================================================
--- test/Assembler/upgrade-loop-metadata.ll	(revision 0)
+++ test/Assembler/upgrade-loop-metadata.ll	(working copy)
@@ -0,0 +1,41 @@
+; Test to make sure loop vectorizer metadata is automatically upgraded.
+;
+; Run using opt as well to ensure that the metadata is upgraded when parsing
+; assembly.
+;
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+; RUN: opt -S < %s | FileCheck %s
+
+define void @_Z28loop_with_vectorize_metadatav() {
+entry:
+  %i = alloca i32, align 4
+  store i32 0, i32* %i, align 4
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.inc, %entry
+  %0 = load i32* %i, align 4
+  %cmp = icmp slt i32 %0, 16
+  br i1 %cmp, label %for.body, label %for.end, !llvm.loop !1
+
+for.body:                                         ; preds = %for.cond
+  br label %for.inc
+
+for.inc:                                          ; preds = %for.body
+  %1 = load i32* %i, align 4
+  %inc = add nsw i32 %1, 1
+  store i32 %inc, i32* %i, align 4
+  br label %for.cond
+
+for.end:                                          ; preds = %for.cond
+  ret void
+}
+
+; CHECK: !{metadata !"llvm.loop.vectorize.unroll", i32 4}
+; CHECK: !{metadata !"llvm.loop.vectorize.width", i32 8}
+; CHECK: !{metadata !"llvm.loop.vectorize.enable", i1 true}
+
+!0 = metadata !{metadata !"clang version 3.5.0 (trunk 211528)"}
+!1 = metadata !{metadata !1, metadata !2, metadata !3, metadata !4, metadata !4}
+!2 = metadata !{metadata !"llvm.vectorizer.unroll", i32 4}
+!3 = metadata !{metadata !"llvm.vectorizer.width", i32 8}
+!4 = metadata !{metadata !"llvm.vectorizer.enable", i1 true}
Index: test/Bitcode/upgrade-loop-metadata.ll
===================================================================
--- test/Bitcode/upgrade-loop-metadata.ll	(revision 0)
+++ test/Bitcode/upgrade-loop-metadata.ll	(working copy)
@@ -0,0 +1,37 @@
+; Test to make sure loop vectorizer metadata is automatically upgraded.
+;
+; RUN: llvm-dis < %s.bc | FileCheck %s
+
+define void @_Z28loop_with_vectorize_metadatav() {
+entry:
+  %i = alloca i32, align 4
+  store i32 0, i32* %i, align 4
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.inc, %entry
+  %0 = load i32* %i, align 4
+  %cmp = icmp slt i32 %0, 16
+  br i1 %cmp, label %for.body, label %for.end, !llvm.loop !1
+
+for.body:                                         ; preds = %for.cond
+  br label %for.inc
+
+for.inc:                                          ; preds = %for.body
+  %1 = load i32* %i, align 4
+  %inc = add nsw i32 %1, 1
+  store i32 %inc, i32* %i, align 4
+  br label %for.cond
+
+for.end:                                          ; preds = %for.cond
+  ret void
+}
+
+; CHECK: !{metadata !"llvm.loop.vectorize.unroll", i32 4}
+; CHECK: !{metadata !"llvm.loop.vectorize.width", i32 8}
+; CHECK: !{metadata !"llvm.loop.vectorize.enable", i1 true}
+
+!0 = metadata !{metadata !"clang version 3.5.0 (trunk 211528)"}
+!1 = metadata !{metadata !1, metadata !2, metadata !3, metadata !4, metadata !4}
+!2 = metadata !{metadata !"llvm.vectorizer.unroll", i32 4}
+!3 = metadata !{metadata !"llvm.vectorizer.width", i32 8}
+!4 = metadata !{metadata !"llvm.vectorizer.enable", i1 true}
Index: test/Bitcode/upgrade-loop-metadata.ll.bc
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: test/Bitcode/upgrade-loop-metadata.ll.bc
===================================================================
--- test/Bitcode/upgrade-loop-metadata.ll.bc	(revision 0)
+++ test/Bitcode/upgrade-loop-metadata.ll.bc	(working copy)

Property changes on: test/Bitcode/upgrade-loop-metadata.ll.bc
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: test/CodeGen/PowerPC/early-ret2.ll
===================================================================
--- test/CodeGen/PowerPC/early-ret2.ll	(revision 211528)
+++ test/CodeGen/PowerPC/early-ret2.ll	(working copy)
@@ -11,7 +11,7 @@
   br i1 undef, label %while.end, label %while.body
 
 while.body:                                       ; preds = %while.body, %while.body.lr.ph
-  br i1 false, label %while.end, label %while.body, !llvm.vectorizer.already_vectorized !0
+  br i1 false, label %while.end, label %while.body, !llvm.loop.vectorize.already_vectorized !0
 
 while.end:                                        ; preds = %while.body, %while.body.lr.ph, %entry
   ret void
Index: test/Transforms/LoopUnroll/unroll-pragmas.ll
===================================================================
--- test/Transforms/LoopUnroll/unroll-pragmas.ll	(revision 211528)
+++ test/Transforms/LoopUnroll/unroll-pragmas.ll	(working copy)
@@ -51,7 +51,7 @@
   ret void
 }
 !1 = metadata !{metadata !1, metadata !2}
-!2 = metadata !{metadata !"llvm.loopunroll.enable", i1 false}
+!2 = metadata !{metadata !"llvm.loop.unroll.enable", i1 false}
 
 ; loop64 has a high enough count that it should *not* be unrolled by
 ; the default unrolling heuristic.  It serves as the control for the
@@ -102,7 +102,7 @@
   ret void
 }
 !3 = metadata !{metadata !3, metadata !4}
-!4 = metadata !{metadata !"llvm.loopunroll.enable", i1 true}
+!4 = metadata !{metadata !"llvm.loop.unroll.enable", i1 true}
 
 ; #pragma clang loop unroll_count(4)
 ; Loop should be unrolled 4 times.
@@ -132,7 +132,7 @@
   ret void
 }
 !5 = metadata !{metadata !5, metadata !6}
-!6 = metadata !{metadata !"llvm.loopunroll.count", i32 4}
+!6 = metadata !{metadata !"llvm.loop.unroll.count", i32 4}
 
 
 ; #pragma clang loop unroll_count(enable) unroll_count(4)
@@ -255,7 +255,7 @@
   ret void
 }
 !10 = metadata !{metadata !10, metadata !11}
-!11 = metadata !{metadata !"llvm.loopunroll.count", i32 1}
+!11 = metadata !{metadata !"llvm.loop.unroll.count", i32 1}
 
 ; #pragma clang loop unroll(enable)
 ; Loop has very high loop count (1 million) and full unrolling was requested.
Index: test/Transforms/LoopVectorize/X86/already-vectorized.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/already-vectorized.ll	(revision 211528)
+++ test/Transforms/LoopVectorize/X86/already-vectorized.ll	(working copy)
@@ -40,7 +40,7 @@
 
 ; Now, we check for the Hint metadata
 ; CHECK: [[vect]] = metadata !{metadata [[vect]], metadata [[width:![0-9]+]], metadata [[unroll:![0-9]+]]}
-; CHECK: [[width]] = metadata !{metadata !"llvm.vectorizer.width", i32 1}
-; CHECK: [[unroll]] = metadata !{metadata !"llvm.vectorizer.unroll", i32 1}
+; CHECK: [[width]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
+; CHECK: [[unroll]] = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 1}
 ; CHECK: [[scalar]] = metadata !{metadata [[scalar]], metadata [[width]], metadata [[unroll]]}
 
Index: test/Transforms/LoopVectorize/X86/metadata-enable.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/metadata-enable.ll	(revision 211528)
+++ test/Transforms/LoopVectorize/X86/metadata-enable.ll	(working copy)
@@ -9,8 +9,9 @@
 ; RUN: opt < %s -mcpu=corei7 -Oz -loop-vectorize -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=OzVEC2
 ; RUN: opt < %s -mcpu=corei7 -O3 -disable-loop-vectorization -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DIS
 
-; This file tests the llvm.vectorizer.pragma forcing vectorization even when
-; optimization levels are too low, or when vectorization is disabled.
+; This file tests the llvm.loop.vectorize.enable metadata forcing
+; vectorization even when optimization levels are too low, or when
+; vectorization is disabled.
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
@@ -170,6 +171,6 @@
 }
 
 !0 = metadata !{metadata !0, metadata !1}
-!1 = metadata !{metadata !"llvm.vectorizer.enable", i1 1}
+!1 = metadata !{metadata !"llvm.loop.vectorize.enable", i1 1}
 !2 = metadata !{metadata !2, metadata !3}
-!3 = metadata !{metadata !"llvm.vectorizer.enable", i1 0}
+!3 = metadata !{metadata !"llvm.loop.vectorize.enable", i1 0}
Index: test/Transforms/LoopVectorize/X86/vect.omp.force.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/vect.omp.force.ll	(revision 211528)
+++ test/Transforms/LoopVectorize/X86/vect.omp.force.ll	(working copy)
@@ -53,7 +53,7 @@
 }
 
 !1 = metadata !{metadata !1, metadata !2}
-!2 = metadata !{metadata !"llvm.vectorizer.enable", i1 true}
+!2 = metadata !{metadata !"llvm.loop.vectorize.enable", i1 true}
 
 ;
 ; This method will not be vectorized, as scalar cost is lower than any of vector costs.
Index: test/Transforms/LoopVectorize/X86/vect.omp.force.small-tc.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/vect.omp.force.small-tc.ll	(revision 211528)
+++ test/Transforms/LoopVectorize/X86/vect.omp.force.small-tc.ll	(working copy)
@@ -44,7 +44,7 @@
 }
 
 !1 = metadata !{metadata !1, metadata !2}
-!2 = metadata !{metadata !"llvm.vectorizer.enable", i1 true}
+!2 = metadata !{metadata !"llvm.loop.vectorize.enable", i1 true}
 
 ;
 ; This loop will not be vectorized as the trip count is below the threshold.
Index: test/Transforms/LoopVectorize/metadata-unroll.ll
===================================================================
--- test/Transforms/LoopVectorize/metadata-unroll.ll	(revision 211528)
+++ test/Transforms/LoopVectorize/metadata-unroll.ll	(working copy)
@@ -38,4 +38,4 @@
 }
 
 !0 = metadata !{metadata !0, metadata !1}
-!1 = metadata !{metadata !"llvm.vectorizer.unroll", i32 2}
+!1 = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 2}
Index: test/Transforms/LoopVectorize/metadata-width.ll
===================================================================
--- test/Transforms/LoopVectorize/metadata-width.ll	(revision 211528)
+++ test/Transforms/LoopVectorize/metadata-width.ll	(working copy)
@@ -28,4 +28,4 @@
 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
 
 !0 = metadata !{metadata !0, metadata !1}
-!1 = metadata !{metadata !"llvm.vectorizer.width", i32 8}
+!1 = metadata !{metadata !"llvm.loop.vectorize.width", i32 8}
Index: test/Transforms/LoopVectorize/vect.omp.persistence.ll
===================================================================
--- test/Transforms/LoopVectorize/vect.omp.persistence.ll	(revision 211528)
+++ test/Transforms/LoopVectorize/vect.omp.persistence.ll	(working copy)
@@ -18,7 +18,7 @@
 ;
 ; Test #1
 ;
-; Ensure that "llvm.vectorizer.enable" metadata was not lost prior to LoopVectorize pass.
+; Ensure that "llvm.loop.vectorize.enable" metadata was not lost prior to LoopVectorize pass.
 ; In past LoopRotate was clearing that metadata.
 ;
 ; The source C code is:
@@ -62,12 +62,12 @@
 }
 
 !1 = metadata !{metadata !1, metadata !2}
-!2 = metadata !{metadata !"llvm.vectorizer.enable", i1 true}
+!2 = metadata !{metadata !"llvm.loop.vectorize.enable", i1 true}
 
 ;
 ; Test #2
 ;
-; Ensure that "llvm.vectorizer.enable" metadata was not lost even
+; Ensure that "llvm.loop.vectorize.enable" metadata was not lost even
 ; if loop was not rotated (see http://reviews.llvm.org/D3348#comment-4).
 ;
 define i32 @nonrotated(i32 %a) {
@@ -85,4 +85,4 @@
 }
 
 !3 = metadata !{metadata !3, metadata !4}
-!4 = metadata !{metadata !"llvm.vectorizer.enable", i1 true}
+!4 = metadata !{metadata !"llvm.loop.vectorize.enable", i1 true}
Index: test/Transforms/LoopVectorize/vectorize-once.ll
===================================================================
--- test/Transforms/LoopVectorize/vectorize-once.ll	(revision 211528)
+++ test/Transforms/LoopVectorize/vectorize-once.ll	(working copy)
@@ -69,9 +69,9 @@
 attributes #0 = { nounwind readonly ssp uwtable "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "realign-stack" "relocation-model"="pic" "ssp-buffers-size"="8" }
 
 ; CHECK: !0 = metadata !{metadata !0, metadata !1, metadata !2}
-; CHECK: !1 = metadata !{metadata !"llvm.vectorizer.width", i32 1}
-; CHECK: !2 = metadata !{metadata !"llvm.vectorizer.unroll", i32 1}
+; CHECK: !1 = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
+; CHECK: !2 = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 1}
 ; CHECK: !3 = metadata !{metadata !3, metadata !1, metadata !2}
 
 !0 = metadata !{metadata !0, metadata !1}
-!1 = metadata !{metadata !"llvm.vectorizer.width", i32 1}
+!1 = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to