On Fri, Jul 18, 2014 at 4:08 PM, Tyler Nowicki <[email protected]> wrote:
> Looks like the llvm patch was accidentally overwritten by the clang patch.
>
Whoops. Sorry. Here are both patches again.
Mark
>
> Tyler
>
> On Jul 18, 2014, at 4:03 PM, Mark Heffernan <[email protected]> wrote:
>
> Here's the updated patches. llvm.loop.vectorize.interleave is now
> llvm.loop.interleave.count.
>
> Mark
>
> On Fri, Jul 18, 2014 at 2:25 PM, Mark Heffernan <[email protected]> wrote:
>
>> On Fri, Jul 18, 2014 at 2:11 PM, Tyler Nowicki <[email protected]>
>> wrote:
>>
>>> Perhaps you could rename 'loop.vectorize.unroll' to
>>> 'loop.interleave.count'. That way in a future patch we could add
>>> 'loop.interleave.enable'.
>>>
>>> What do you think?
>>>
>>
>> Sounds reasonable. Happy to change it to whatever is most appropriate.
>>
>> Mark
>>
>>
>>>
>>> Tyler
>>>
>>> On Jul 18, 2014, at 1:51 PM, Hal Finkel <[email protected]> wrote:
>>>
>>> > Nadav, Arnold,
>>> >
>>> > I think this makes sense. Do either of you object?
>>> >
>>> > -Hal
>>> >
>>> > ----- Original Message -----
>>> >> From: "Mark Heffernan" <[email protected]>
>>> >> To: [email protected], "cfe-commits" <[email protected]>,
>>> "Hal Finkel" <[email protected]>, "Tyler
>>> >> Nowicki" <[email protected]>
>>> >> Sent: Friday, July 18, 2014 3:44:00 PM
>>> >> Subject: Rename metadata llvm.loop.vectorize.unroll to
>>> llvm.loop.vectorize.interleave
>>> >>
>>> >>
>>> >> This patch rename metadata llvm.loop.vectorize.unroll to
>>> >> llvm.loop.vectorize.interleave to avoid confusion with the
>>> >> concatenation unroller metadata (llvm.loop.unroll). It fell out of a
>>> >> discussion on patch http://reviews.llvm.org/D4576 . On that patch
>>> >> there was some confusion about whether llvm.loop.vectorize.unroll
>>> >> controlled the traditional (concatenation) loop unroller. And IIRC
>>> >> this isn't the first time there has been this confusion. Renaming
>>> >> vectorize.unroll to vectorize.interleave also more closely matches
>>> >> the pragma which generates the metadata (#pragma clang loop
>>> >> interleave_count). There are still lots of uses of "unroll" within
>>> >> the code in function/variable names and comments. I have no
>>> >> intention of changing those.
>>> >>
>>> >>
>>> >> Mark
>>> >
>>> > --
>>> > Hal Finkel
>>> > Assistant Computational Scientist
>>> > Leadership Computing Facility
>>> > Argonne National Laboratory
>>>
>>>
>>
> <rename.llvm.patch><rename.clang.patch>
>
>
>
Index: lib/CodeGen/CGLoopInfo.cpp
===================================================================
--- lib/CodeGen/CGLoopInfo.cpp (revision 213406)
+++ lib/CodeGen/CGLoopInfo.cpp (working copy)
@@ -39,7 +39,7 @@
// Setting vectorizer.unroll
if (Attrs.VectorizerUnroll > 0) {
- Value *Vals[] = { MDString::get(Ctx, "llvm.loop.vectorize.unroll"),
+ Value *Vals[] = { MDString::get(Ctx, "llvm.loop.interleave.count"),
ConstantInt::get(Type::getInt32Ty(Ctx),
Attrs.VectorizerUnroll) };
Args.push_back(MDNode::get(Ctx, Vals));
Index: lib/CodeGen/CGLoopInfo.h
===================================================================
--- lib/CodeGen/CGLoopInfo.h (revision 213406)
+++ lib/CodeGen/CGLoopInfo.h (working copy)
@@ -46,7 +46,7 @@
/// \brief llvm.loop.vectorize.width
unsigned VectorizerWidth;
- /// \brief llvm.loop.vectorize.unroll
+ /// \brief llvm.loop.interleave.count
unsigned VectorizerUnroll;
};
Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp (revision 213406)
+++ lib/CodeGen/CGStmt.cpp (working copy)
@@ -586,7 +586,7 @@
break;
case LoopHintAttr::Interleave:
case LoopHintAttr::InterleaveCount:
- MetadataName = "llvm.loop.vectorize.unroll";
+ MetadataName = "llvm.loop.interleave.count";
break;
case LoopHintAttr::Unroll:
MetadataName = "llvm.loop.unroll.enable";
Index: test/CodeGen/pragma-loop.cpp
===================================================================
--- test/CodeGen/pragma-loop.cpp (revision 213406)
+++ test/CodeGen/pragma-loop.cpp (working copy)
@@ -111,7 +111,7 @@
// 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.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: ![[INTERLEAVE_4]] = metadata !{metadata !"llvm.loop.interleave.count", 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.loop.unroll.enable", i1 false}
@@ -119,11 +119,11 @@
// CHECK: ![[LOOP_3]] = metadata !{metadata ![[LOOP_3]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[ENABLE_1:.*]]}
// 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.loop.vectorize.unroll", i32 2}
+// CHECK: ![[INTERLEAVE_2]] = metadata !{metadata !"llvm.loop.interleave.count", 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.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.loop.vectorize.unroll", i32 8}
+// CHECK: ![[INTERLEAVE_8]] = metadata !{metadata !"llvm.loop.interleave.count", i32 8}
// CHECK: ![[LOOP_8]] = metadata !{metadata ![[LOOP_8]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_2:.*]], metadata ![[WIDTH_2:.*]]}
Index: docs/LangRef.rst
===================================================================
--- docs/LangRef.rst (revision 213406)
+++ docs/LangRef.rst (working copy)
@@ -2910,38 +2910,50 @@
br i1 %exitcond, label %._crit_edge, label %.lr.ph, !llvm.loop !0
...
!0 = metadata !{ metadata !0, metadata !1 }
- !1 = metadata !{ metadata !"llvm.loop.vectorize.width", i32 4 }
+ !1 = metadata !{ metadata !"llvm.loop.unroll.count", i32 4 }
-'``llvm.loop.vectorize``'
-^^^^^^^^^^^^^^^^^^^^^^^^^
+'``llvm.loop.vectorize``' and '``llvm.loop.interleave``'
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Metadata prefixed with ``llvm.loop.vectorize`` is used to control
-per-loop vectorization parameters such as vectorization width and
-interleave count. ``llvm.loop.vectorize`` metadata should be used in
+Metadata prefixed with ``llvm.loop.vectorize`` or ``llvm.loop.interleave`` are
+used to control per-loop vectorization and interleaving parameters such as
+vectorization width and interleave count. These metadata should be used in
conjunction with ``llvm.loop`` loop identification metadata. The
-``llvm.loop.vectorize`` metadata are only optimization hints and the
-vectorizer will only vectorize loops if it believes it is safe to do
-so. The ``llvm.mem.parallel_loop_access`` metadata which contains
-information about loop-carried memory dependencies can be helpful in
-determining the safety of loop vectorization.
+``llvm.loop.vectorize`` and ``llvm.loop.interleave`` metadata are only
+optimization hints and the optimizer will only interleave and vectorize loops if
+it believes it is safe to do so. The ``llvm.mem.parallel_loop_access`` metadata
+which contains information about loop-carried memory dependencies can be helpful
+in determining the safety of these transformations.
-'``llvm.loop.vectorize.unroll``' Metadata
+'``llvm.loop.interleave.count``' Metadata
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-This metadata suggests an interleave count to the loop vectorizer.
-The first operand is the string ``llvm.loop.vectorize.unroll`` and the
+This metadata suggests an interleave count to the loop interleaver.
+The first operand is the string ``llvm.loop.interleave.count`` and the
second operand is an integer specifying the interleave count. For
example:
.. code-block:: llvm
- !0 = metadata !{ metadata !"llvm.loop.vectorize.unroll", i32 4 }
+ !0 = metadata !{ metadata !"llvm.loop.interleave.count", i32 4 }
-Note that setting ``llvm.loop.vectorize.unroll`` to 1 disables
-interleaving multiple iterations of the loop. If
-``llvm.loop.vectorize.unroll`` is set to 0 then the interleave count
-will be determined automatically.
+Note that setting ``llvm.loop.interleave.count`` to 1 disables interleaving
+multiple iterations of the loop. If ``llvm.loop.interleave.count`` is set to 0
+then the interleave count will be determined automatically.
+'``llvm.loop.vectorize.enable``' Metadata
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This metadata selectively enables or disables vectorization for the loop. The
+first operand is the string ``llvm.loop.vectorize.enable`` and the second operand
+is a bit. If the bit operand value is 1 vectorization is enabled. A value of
+0 disables vectorization:
+
+.. code-block:: llvm
+
+ !0 = metadata !{ metadata !"llvm.loop.vectorize.enable", i1 0 }
+ !1 = metadata !{ metadata !"llvm.loop.vectorize.enable", i1 1 }
+
'``llvm.loop.vectorize.width``' Metadata
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Index: docs/ReleaseNotes.rst
===================================================================
--- docs/ReleaseNotes.rst (revision 213406)
+++ docs/ReleaseNotes.rst (working copy)
@@ -57,7 +57,9 @@
unwinding information.
* The prefix for loop vectorizer hint metadata has been changed from
- ``llvm.vectorizer`` to ``llvm.loop.vectorize``.
+ ``llvm.vectorizer`` to ``llvm.loop.vectorize``. In addition,
+ ``llvm.vectorizer.unroll`` metadata has been renamed
+ ``llvm.loop.interleave.count``.
* Some backends previously implemented Atomic NAND(x,y) as ``x & ~y``. Now
all backends implement it as ``~(x & y)``, matching the semantics of GCC 4.4
Index: lib/IR/AutoUpgrade.cpp
===================================================================
--- lib/IR/AutoUpgrade.cpp (revision 213406)
+++ lib/IR/AutoUpgrade.cpp (working copy)
@@ -580,7 +580,9 @@
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.");
+ if (String == "llvm.vectorizer.unroll") {
+ String = "llvm.loop.interleave.count";
+ } else if (String.find(OldPrefix) == 0) {
+ String.replace(0, OldPrefix.size(), "llvm.loop.vectorize.");
}
}
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp (revision 213406)
+++ lib/Transforms/Vectorize/LoopVectorize.cpp (working copy)
@@ -942,8 +942,8 @@
<< "LV: Unrolling disabled by the pass manager\n");
}
- /// Return the loop vectorizer metadata prefix.
- static StringRef Prefix() { return "llvm.loop.vectorize."; }
+ /// Return the loop metadata prefix.
+ static StringRef Prefix() { return "llvm.loop."; }
MDNode *createHint(LLVMContext &Context, StringRef Name, unsigned V) const {
SmallVector<Value*, 2> Vals;
@@ -965,8 +965,10 @@
for (unsigned i = 1, ie = LoopID->getNumOperands(); i < ie; ++i)
Vals.push_back(LoopID->getOperand(i));
- Vals.push_back(createHint(Context, Twine(Prefix(), "width").str(), Width));
- Vals.push_back(createHint(Context, Twine(Prefix(), "unroll").str(), 1));
+ Vals.push_back(
+ createHint(Context, Twine(Prefix(), "vectorize.width").str(), Width));
+ Vals.push_back(
+ createHint(Context, Twine(Prefix(), "interleave.count").str(), 1));
MDNode *NewLoopID = MDNode::get(Context, Vals);
// Set operand 0 to refer to the loop id itself.
@@ -1037,7 +1039,7 @@
if (!S)
continue;
- // Check if the hint starts with the vectorizer prefix.
+ // Check if the hint starts with the loop metadata prefix.
StringRef Hint = S->getString();
if (!Hint.startswith(Prefix()))
continue;
@@ -1055,22 +1057,22 @@
if (!C) return;
unsigned Val = C->getZExtValue();
- if (Hint == "width") {
+ if (Hint == "vectorize.width") {
if (isPowerOf2_32(Val) && Val <= MaxVectorWidth)
Width = Val;
else
DEBUG(dbgs() << "LV: ignoring invalid width hint metadata\n");
- } else if (Hint == "unroll") {
- if (isPowerOf2_32(Val) && Val <= MaxUnrollFactor)
- Unroll = Val;
- else
- DEBUG(dbgs() << "LV: ignoring invalid unroll hint metadata\n");
- } else if (Hint == "enable") {
+ } else if (Hint == "vectorize.enable") {
if (C->getBitWidth() == 1)
Force = Val == 1 ? LoopVectorizeHints::FK_Enabled
: LoopVectorizeHints::FK_Disabled;
else
DEBUG(dbgs() << "LV: ignoring invalid enable hint metadata\n");
+ } else if (Hint == "interleave.count") {
+ if (isPowerOf2_32(Val) && Val <= MaxUnrollFactor)
+ Unroll = Val;
+ else
+ DEBUG(dbgs() << "LV: ignoring invalid unroll hint metadata\n");
} else {
DEBUG(dbgs() << "LV: ignoring unknown hint " << Hint << '\n');
}
Index: test/Assembler/upgrade-loop-metadata.ll
===================================================================
--- test/Assembler/upgrade-loop-metadata.ll (revision 213406)
+++ test/Assembler/upgrade-loop-metadata.ll (working copy)
@@ -30,7 +30,7 @@
ret void
}
-; CHECK: !{metadata !"llvm.loop.vectorize.unroll", i32 4}
+; CHECK: !{metadata !"llvm.loop.interleave.count", i32 4}
; CHECK: !{metadata !"llvm.loop.vectorize.width", i32 8}
; CHECK: !{metadata !"llvm.loop.vectorize.enable", i1 true}
Index: test/Bitcode/upgrade-loop-metadata.ll
===================================================================
--- test/Bitcode/upgrade-loop-metadata.ll (revision 213406)
+++ test/Bitcode/upgrade-loop-metadata.ll (working copy)
@@ -26,7 +26,7 @@
ret void
}
-; CHECK: !{metadata !"llvm.loop.vectorize.unroll", i32 4}
+; CHECK: !{metadata !"llvm.loop.interleave.count", i32 4}
; CHECK: !{metadata !"llvm.loop.vectorize.width", i32 8}
; CHECK: !{metadata !"llvm.loop.vectorize.enable", i1 true}
Index: test/Transforms/LoopVectorize/X86/already-vectorized.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/already-vectorized.ll (revision 213406)
+++ test/Transforms/LoopVectorize/X86/already-vectorized.ll (working copy)
@@ -41,6 +41,6 @@
; 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.loop.vectorize.width", i32 1}
-; CHECK: [[unroll]] = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 1}
+; CHECK: [[unroll]] = metadata !{metadata !"llvm.loop.interleave.count", i32 1}
; CHECK: [[scalar]] = metadata !{metadata [[scalar]], metadata [[width]], metadata [[unroll]]}
Index: test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll (revision 213406)
+++ test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll (working copy)
@@ -150,7 +150,7 @@
!25 = metadata !{i32 12, i32 8, metadata !26, null}
!26 = metadata !{i32 786443, metadata !1, metadata !7, i32 12, i32 3, i32 0, i32 3}
!27 = metadata !{metadata !27, metadata !28, metadata !29}
-!28 = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 1}
+!28 = metadata !{metadata !"llvm.loop.interleave.count", i32 1}
!29 = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
!30 = metadata !{i32 13, i32 5, metadata !26, null}
!31 = metadata !{i32 14, i32 1, metadata !7, null}
Index: test/Transforms/LoopVectorize/metadata-unroll.ll
===================================================================
--- test/Transforms/LoopVectorize/metadata-unroll.ll (revision 213406)
+++ test/Transforms/LoopVectorize/metadata-unroll.ll (working copy)
@@ -38,4 +38,4 @@
}
!0 = metadata !{metadata !0, metadata !1}
-!1 = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 2}
+!1 = metadata !{metadata !"llvm.loop.interleave.count", i32 2}
Index: test/Transforms/LoopVectorize/vectorize-once.ll
===================================================================
--- test/Transforms/LoopVectorize/vectorize-once.ll (revision 213406)
+++ test/Transforms/LoopVectorize/vectorize-once.ll (working copy)
@@ -70,7 +70,7 @@
; CHECK: !0 = metadata !{metadata !0, metadata !1, metadata !2}
; CHECK: !1 = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
-; CHECK: !2 = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 1}
+; CHECK: !2 = metadata !{metadata !"llvm.loop.interleave.count", i32 1}
; CHECK: !3 = metadata !{metadata !3, metadata !1, metadata !2}
!0 = metadata !{metadata !0, metadata !1}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits