<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - If "#pragma clang loop interleave_count(3)" is specified for the loop, it is ignored."
href="https://bugs.llvm.org/show_bug.cgi?id=48167">48167</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>If "#pragma clang loop interleave_count(3)" is specified for the loop, it is ignored.
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>fj8765ah@aa.jp.fujitsu.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>"#pragma clang interleave_count(NUM)" appears to ignore NUM values that are not
powers of 2.
I think it is better to give priority to what is specified by pragma.
Does setting it to a value other than a power of 2 cause problems?
- interleave.c
void foo(double * restrict a,
double * restrict b,
double * restrict c,
int n) {
#ifdef PRAGMA
#pragma clang loop interleave_count(_NUM)
#endif
for (int i=0;i<n;i++)
c[i] = a[i] + b[i];
return;
}
If "#pragma clang interleave_count(3)" is specified, the interleave is 2.
$ clang -O3 interleave.c -Rpass=loop-vectorize -S
interleave.c:8:3: remark: vectorized loop (vectorization width: 2, interleaved
count: 2) [-Rpass=loop-vectorize]
for (int i=0;i<n;i++)
^
$ clang -O3 interleave.c -Rpass=loop-vectorize -S -DPRAGMA -D_NUM=1
interleave.c:8:3: remark: vectorized loop (vectorization width: 2, interleaved
count: 1) [-Rpass=loop-vectorize]
for (int i=0;i<n;i++)
^
$ clang -O3 interleave.c -Rpass=loop-vectorize -S -DPRAGMA -D_NUM=2
interleave.c:8:3: remark: vectorized loop (vectorization width: 2, interleaved
count: 2) [-Rpass=loop-vectorize]
for (int i=0;i<n;i++)
^
$ clang -O3 interleave.c -Rpass=loop-vectorize -S -DPRAGMA -D_NUM=3
interleave.c:8:3: remark: vectorized loop (vectorization width: 2, interleaved
count: 2) [-Rpass=loop-vectorize]
for (int i=0;i<n;i++)
^
I think it is set in the following part of the
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp" file.
If the value is not a power of 2, the if statement on line 235 is false and
ignored.
59 bool LoopVectorizeHints::Hint::validate(unsigned Val) {
60 switch (Kind) {
61 case HK_WIDTH:
62 return isPowerOf2_32(Val) && Val <=
VectorizerParams::MaxVectorWidth;
63 case HK_UNROLL:
64 return isPowerOf2_32(Val) && Val <= MaxInterleaveFactor;
65 case HK_FORCE:
66 return (Val <= 1);
67 case HK_ISVECTORIZED:
68 case HK_PREDICATE:
69 return (Val == 0 || Val == 1);
70 }
71 return false;
72 }
...
223 void LoopVectorizeHints::setHint(StringRef Name, Metadata *Arg) {
224 if (!Name.startswith(Prefix()))
225 return;
226 Name = Name.substr(Prefix().size(), StringRef::npos);
227
228 const ConstantInt *C = mdconst::dyn_extract<ConstantInt>(Arg);
229 if (!C)
230 return;
231 unsigned Val = C->getZExtValue();
232
233 Hint *Hints[] = {&Width, &Interleave, &Force, &IsVectorized,
&Predicate};
234 for (auto H : Hints) {
235 if (Name == H->Name) {
236 if (H->validate(Val))
237 H->Value = Val;
238 else
239 LLVM_DEBUG(dbgs() << "LV: ignoring invalid hint '" << Name <<
"'\n");
240 break;
241 }
242 }
243 }</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>