llvm.org GIT mirror llvm / bc7f1ab
Rename metadata llvm.loop.vectorize.unroll to llvm.loop.vectorize.interleave. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213588 91177308-0d34-0410-b5e6-96231b3b80d8 Mark Heffernan 5 years ago
10 changed file(s) with 64 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
29092909 br i1 %exitcond, label %._crit_edge, label %.lr.ph, !llvm.loop !0
29102910 ...
29112911 !0 = metadata !{ metadata !0, metadata !1 }
2912 !1 = metadata !{ metadata !"llvm.loop.vectorize.width", i32 4 }
2913
2914 '``llvm.loop.vectorize``'
2915 ^^^^^^^^^^^^^^^^^^^^^^^^^
2916
2917 Metadata prefixed with ``llvm.loop.vectorize`` is used to control
2918 per-loop vectorization parameters such as vectorization width and
2919 interleave count. ``llvm.loop.vectorize`` metadata should be used in
2912 !1 = metadata !{ metadata !"llvm.loop.unroll.count", i32 4 }
2913
2914 '``llvm.loop.vectorize``' and '``llvm.loop.interleave``'
2915 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2916
2917 Metadata prefixed with ``llvm.loop.vectorize`` or ``llvm.loop.interleave`` are
2918 used to control per-loop vectorization and interleaving parameters such as
2919 vectorization width and interleave count. These metadata should be used in
29202920 conjunction with ``llvm.loop`` loop identification metadata. The
2921 ``llvm.loop.vectorize`` metadata are only optimization hints and the
2922 vectorizer will only vectorize loops if it believes it is safe to do
2923 so. The ``llvm.mem.parallel_loop_access`` metadata which contains
2924 information about loop-carried memory dependencies can be helpful in
2925 determining the safety of loop vectorization.
2926
2927 '``llvm.loop.vectorize.unroll``' Metadata
2921 ``llvm.loop.vectorize`` and ``llvm.loop.interleave`` metadata are only
2922 optimization hints and the optimizer will only interleave and vectorize loops if
2923 it believes it is safe to do so. The ``llvm.mem.parallel_loop_access`` metadata
2924 which contains information about loop-carried memory dependencies can be helpful
2925 in determining the safety of these transformations.
2926
2927 '``llvm.loop.interleave.count``' Metadata
29282928 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29292929
2930 This metadata suggests an interleave count to the loop vectorizer.
2931 The first operand is the string ``llvm.loop.vectorize.unroll`` and the
2930 This metadata suggests an interleave count to the loop interleaver.
2931 The first operand is the string ``llvm.loop.interleave.count`` and the
29322932 second operand is an integer specifying the interleave count. For
29332933 example:
29342934
29352935 .. code-block:: llvm
29362936
2937 !0 = metadata !{ metadata !"llvm.loop.vectorize.unroll", i32 4 }
2938
2939 Note that setting ``llvm.loop.vectorize.unroll`` to 1 disables
2940 interleaving multiple iterations of the loop. If
2941 ``llvm.loop.vectorize.unroll`` is set to 0 then the interleave count
2942 will be determined automatically.
2937 !0 = metadata !{ metadata !"llvm.loop.interleave.count", i32 4 }
2938
2939 Note that setting ``llvm.loop.interleave.count`` to 1 disables interleaving
2940 multiple iterations of the loop. If ``llvm.loop.interleave.count`` is set to 0
2941 then the interleave count will be determined automatically.
2942
2943 '``llvm.loop.vectorize.enable``' Metadata
2944 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2945
2946 This metadata selectively enables or disables vectorization for the loop. The
2947 first operand is the string ``llvm.loop.vectorize.enable`` and the second operand
2948 is a bit. If the bit operand value is 1 vectorization is enabled. A value of
2949 0 disables vectorization:
2950
2951 .. code-block:: llvm
2952
2953 !0 = metadata !{ metadata !"llvm.loop.vectorize.enable", i1 0 }
2954 !1 = metadata !{ metadata !"llvm.loop.vectorize.enable", i1 1 }
29432955
29442956 '``llvm.loop.vectorize.width``' Metadata
29452957 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5656 unwinding information.
5757
5858 * The prefix for loop vectorizer hint metadata has been changed from
59 ``llvm.vectorizer`` to ``llvm.loop.vectorize``.
59 ``llvm.vectorizer`` to ``llvm.loop.vectorize``. In addition,
60 ``llvm.vectorizer.unroll`` metadata has been renamed
61 ``llvm.loop.interleave.count``.
6062
6163 * Some backends previously implemented Atomic NAND(x,y) as ``x & ~y``. Now
6264 all backends implement it as ``~(x & y)``, matching the semantics of GCC 4.4
579579
580580 void llvm::UpgradeMDStringConstant(std::string &String) {
581581 const std::string OldPrefix = "llvm.vectorizer.";
582 if (String.find(OldPrefix) == 0) {
583 String.replace(0, OldPrefix.size(), "llvm.loop.vectorize.");
584 }
585 }
582 if (String == "llvm.vectorizer.unroll") {
583 String = "llvm.loop.interleave.count";
584 } else if (String.find(OldPrefix) == 0) {
585 String.replace(0, OldPrefix.size(), "llvm.loop.vectorize.");
586 }
587 }
977977 << "LV: Unrolling disabled by the pass manager\n");
978978 }
979979
980 /// Return the loop vectorizer metadata prefix.
981 static StringRef Prefix() { return "llvm.loop.vectorize."; }
980 /// Return the loop metadata prefix.
981 static StringRef Prefix() { return "llvm.loop."; }
982982
983983 MDNode *createHint(LLVMContext &Context, StringRef Name, unsigned V) const {
984984 SmallVector Vals;
10001000 for (unsigned i = 1, ie = LoopID->getNumOperands(); i < ie; ++i)
10011001 Vals.push_back(LoopID->getOperand(i));
10021002
1003 Vals.push_back(createHint(Context, Twine(Prefix(), "width").str(), Width));
1004 Vals.push_back(createHint(Context, Twine(Prefix(), "unroll").str(), 1));
1003 Vals.push_back(
1004 createHint(Context, Twine(Prefix(), "vectorize.width").str(), Width));
1005 Vals.push_back(
1006 createHint(Context, Twine(Prefix(), "interleave.count").str(), 1));
10051007
10061008 MDNode *NewLoopID = MDNode::get(Context, Vals);
10071009 // Set operand 0 to refer to the loop id itself.
10721074 if (!S)
10731075 continue;
10741076
1075 // Check if the hint starts with the vectorizer prefix.
1077 // Check if the hint starts with the loop metadata prefix.
10761078 StringRef Hint = S->getString();
10771079 if (!Hint.startswith(Prefix()))
10781080 continue;
10901092 if (!C) return;
10911093 unsigned Val = C->getZExtValue();
10921094
1093 if (Hint == "width") {
1095 if (Hint == "vectorize.width") {
10941096 if (isPowerOf2_32(Val) && Val <= MaxVectorWidth)
10951097 Width = Val;
10961098 else
10971099 DEBUG(dbgs() << "LV: ignoring invalid width hint metadata\n");
1098 } else if (Hint == "unroll") {
1099 if (isPowerOf2_32(Val) && Val <= MaxUnrollFactor)
1100 Unroll = Val;
1101 else
1102 DEBUG(dbgs() << "LV: ignoring invalid unroll hint metadata\n");
1103 } else if (Hint == "enable") {
1100 } else if (Hint == "vectorize.enable") {
11041101 if (C->getBitWidth() == 1)
11051102 Force = Val == 1 ? LoopVectorizeHints::FK_Enabled
11061103 : LoopVectorizeHints::FK_Disabled;
11071104 else
11081105 DEBUG(dbgs() << "LV: ignoring invalid enable hint metadata\n");
1106 } else if (Hint == "interleave.count") {
1107 if (isPowerOf2_32(Val) && Val <= MaxUnrollFactor)
1108 Unroll = Val;
1109 else
1110 DEBUG(dbgs() << "LV: ignoring invalid unroll hint metadata\n");
11091111 } else {
11101112 DEBUG(dbgs() << "LV: ignoring unknown hint " << Hint << '\n');
11111113 }
2929 ret void
3030 }
3131
32 ; CHECK: !{metadata !"llvm.loop.vectorize.unroll", i32 4}
32 ; CHECK: !{metadata !"llvm.loop.interleave.count", i32 4}
3333 ; CHECK: !{metadata !"llvm.loop.vectorize.width", i32 8}
3434 ; CHECK: !{metadata !"llvm.loop.vectorize.enable", i1 true}
3535
2525 ret void
2626 }
2727
28 ; CHECK: !{metadata !"llvm.loop.vectorize.unroll", i32 4}
28 ; CHECK: !{metadata !"llvm.loop.interleave.count", i32 4}
2929 ; CHECK: !{metadata !"llvm.loop.vectorize.width", i32 8}
3030 ; CHECK: !{metadata !"llvm.loop.vectorize.enable", i1 true}
3131
4040 ; Now, we check for the Hint metadata
4141 ; CHECK: [[vect]] = metadata !{metadata [[vect]], metadata [[width:![0-9]+]], metadata [[unroll:![0-9]+]]}
4242 ; CHECK: [[width]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
43 ; CHECK: [[unroll]] = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 1}
43 ; CHECK: [[unroll]] = metadata !{metadata !"llvm.loop.interleave.count", i32 1}
4444 ; CHECK: [[scalar]] = metadata !{metadata [[scalar]], metadata [[width]], metadata [[unroll]]}
4545
149149 !25 = metadata !{i32 12, i32 8, metadata !26, null}
150150 !26 = metadata !{i32 786443, metadata !1, metadata !7, i32 12, i32 3, i32 0, i32 3}
151151 !27 = metadata !{metadata !27, metadata !28, metadata !29}
152 !28 = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 1}
152 !28 = metadata !{metadata !"llvm.loop.interleave.count", i32 1}
153153 !29 = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
154154 !30 = metadata !{i32 13, i32 5, metadata !26, null}
155155 !31 = metadata !{i32 14, i32 1, metadata !7, null}
3737 }
3838
3939 !0 = metadata !{metadata !0, metadata !1}
40 !1 = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 2}
40 !1 = metadata !{metadata !"llvm.loop.interleave.count", i32 2}
6969
7070 ; CHECK: !0 = metadata !{metadata !0, metadata !1, metadata !2}
7171 ; CHECK: !1 = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
72 ; CHECK: !2 = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 1}
72 ; CHECK: !2 = metadata !{metadata !"llvm.loop.interleave.count", i32 1}
7373 ; CHECK: !3 = metadata !{metadata !3, metadata !1, metadata !2}
7474
7575 !0 = metadata !{metadata !0, metadata !1}