<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 - [LV] Lost vectorization opportunity"
href="https://bugs.llvm.org/show_bug.cgi?id=36524">36524</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LV] Lost vectorization opportunity
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dneilson@azul.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19965" name="attach_19965" title="Sample IR">attachment 19965</a> <a href="attachment.cgi?id=19965&action=edit" title="Sample IR">[details]</a></span>
Sample IR
IR attached:
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: uwtable
define void @foo() #0 {
entry:
br label %loop
loop:
%0 = phi i64 [ 2, %entry ], [ %3, %loop ]
%1 = and i64 %0, 4294967295
%2 = trunc i64 %0 to i32
%3 = add nuw nsw i64 %1, 1
%4 = icmp sgt i32 %2, 80
br i1 %4, label %exit, label %loop
exit:
ret void
}
attributes #0 = { uwtable "target-cpu"="bdver1"
"target-features"="+sse2,+cx16,-tbm,-avx512ifma,-gfni,-sha,+fma4,-vpclmulqdq,+prfchw,-bmi2,-xsavec,-fsgsbase,+popcnt,+aes,-avx512bitalg,-xsaves,-avx512er,-avx512vnni,-avx512vpopcntdq,-clwb,-avx512f,-clzero,-pku,+mmx,+lwp,-rdpid,+xop,-rdseed,-ibt,+sse4a,-avx512bw,-clflushopt,+xsave,-avx512vbmi2,-avx512vl,-avx512cd,+avx,-vaes,-rtm,-fma,-bmi,-rdrnd,-mwaitx,+sse4.1,+sse4.2,-avx2,+sse,+lzcnt,+pclmul,-prefetchwt1,-f16c,+ssse3,-sgx,-shstk,+cmov,-avx512vbmi,-movbe,-xsaveopt,-avx512dq,-adx,-avx512pf,+sse3"
}
----
When run through the loop vectorizer with ToT we do not vectorize this loop.
However, it did once vectorize in the fairly recent past. There's a bit of a
history on this one...
<a href="https://reviews.llvm.org/rL320463">https://reviews.llvm.org/rL320463</a> -- is the last LoopVectorizer.cpp change that
vectorizes this loop.
<a href="https://reviews.llvm.org/rL320672">https://reviews.llvm.org/rL320672</a> -- breaks the test, with an assertion in
VPlan:
r320672 | dorit.nuzman | 2017-12-14 01:56:31 -0600 (Thu, 14 Dec 2017) | 26
lines
[LV] Support efficient vectorization of an induction with redundant casts
==
Assertion failed: (!hasVectorValue(Key, Part) && "Vector value already set for
part"), function setVectorValue, file lib/Transforms/Vectorize/VPlan.h, line
166.
0 opt 0x000000010b8e44bc
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1 opt 0x000000010b8e4ab9
PrintStackTraceSignalHandler(void*) + 25
2 opt 0x000000010b8e0549 llvm::sys::RunSignalHandlers() +
425
3 opt 0x000000010b8e4e72 SignalHandler(int) + 354
4 libsystem_platform.dylib 0x00007fff64326f5a _sigtramp + 26
5 libdyld.dylib 0x00007fff640a5249 dyldGlobalLockRelease() + 0
6 libsystem_c.dylib 0x00007fff64151312 abort + 127
7 libsystem_c.dylib 0x00007fff64119368 basename_r + 0
8 opt 0x000000010ba87eb0
llvm::VectorizerValueMap::setVectorValue(llvm::Value*, unsigned int,
llvm::Value*) + 160
9 opt 0x000000010ba88100
llvm::InnerLoopVectorizer::recordVectorLoopValueForInductionCast(llvm::InductionDescriptor
const&, llvm::Value*, unsigned int, unsigned int) + 208
10 opt 0x000000010ba89375
llvm::InnerLoopVectorizer::widenIntOrFpInduction(llvm::PHINode*,
llvm::TruncInst*) + 2533
11 opt 0x000000010bac0ed0 (anonymous
namespace)::VPWidenIntOrFpInductionRecipe::execute(llvm::VPTransformState&) +
144
12 opt 0x000000010bb64bfa
llvm::VPBasicBlock::execute(llvm::VPTransformState*) + 842
13 opt 0x000000010bb66037
llvm::VPlan::execute(llvm::VPTransformState*) + 855
14 opt 0x000000010ba9a22e
llvm::LoopVectorizationPlanner::executePlan(llvm::InnerLoopVectorizer&,
llvm::DominatorTree*) + 430
15 opt 0x000000010baa2ad2
llvm::LoopVectorizePass::processLoop(llvm::Loop*) + 8482
<a href="https://reviews.llvm.org/rL322473">https://reviews.llvm.org/rL322473</a> -- Changes the breakage. It's still broken,
but the assert has changed
r322473 | andrei.elovikov | 2018-01-15 04:56:07 -0600 (Mon, 15 Jan 2018) | 24
lines
[LV] Don't call recordVectorLoopValueForInductionCast for newly-created IV from
a trunc.
==
Assertion failed: (!hasScalarValue(Key, Instance) && "Scalar value already
set"), function setScalarValue, file lib/Transforms/Vectorize/VPlan.h, line
173.
0 opt 0x000000010429f82c
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1 opt 0x000000010429fe29
PrintStackTraceSignalHandler(void*) + 25
2 opt 0x000000010429b8b9 llvm::sys::RunSignalHandlers() +
425
3 opt 0x00000001042a01e2 SignalHandler(int) + 354
4 libsystem_platform.dylib 0x00007fff64326f5a _sigtramp + 26
5 libdyld.dylib 0x00007fff640a5249 dyldGlobalLockRelease() + 0
6 libsystem_c.dylib 0x00007fff64151312 abort + 127
7 libsystem_c.dylib 0x00007fff64119368 basename_r + 0
8 opt 0x000000010444662f
llvm::VectorizerValueMap::setScalarValue(llvm::Value*, llvm::VPIteration
const&, llvm::Value*) + 175
9 opt 0x0000000104446143
llvm::InnerLoopVectorizer::recordVectorLoopValueForInductionCast(llvm::InductionDescriptor
const&, llvm::Value*, unsigned int, unsigned int) + 163
10 opt 0x0000000104447ba4
llvm::InnerLoopVectorizer::buildScalarSteps(llvm::Value*, llvm::Value*,
llvm::Value*, llvm::InductionDescriptor const&) + 852
11 opt 0x00000001044474a1
llvm::InnerLoopVectorizer::widenIntOrFpInduction(llvm::PHINode*,
llvm::TruncInst*) + 2721
12 opt 0x0000000104474390
llvm::VPWidenIntOrFpInductionRecipe::execute(llvm::VPTransformState&) + 144
13 opt 0x000000010452300a
llvm::VPBasicBlock::execute(llvm::VPTransformState*) + 842
14 opt 0x0000000104524447
llvm::VPlan::execute(llvm::VPTransformState*) + 855
15 opt 0x000000010446d9ce
llvm::LoopVectorizationPlanner::executePlan(llvm::InnerLoopVectorizer&,
llvm::DominatorTree*) + 430
16 opt 0x0000000104477cc2
llvm::LoopVectorizePass::processLoop(llvm::Loop*) + 8482
<a href="https://reviews.llvm.org/rL326079">https://reviews.llvm.org/rL326079</a> -- The assertion is now gone, but the loop is
no longer vectorized.
r326079 | renato.golin | 2018-02-26 05:06:36 -0600 (Mon, 26 Feb 2018) | 21
lines
[LV] Move isLegalMasked* functions from Legality to CostModel</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>