<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 - [SCEV][Unroll] Assertion `isLoopInvariant(Operands[i], L) && "SCEVAddRecExpr operand is not loop-invariant!"' failed."
href="https://bugs.llvm.org/show_bug.cgi?id=40420">40420</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[SCEV][Unroll] Assertion `isLoopInvariant(Operands[i], L) && "SCEVAddRecExpr operand is not loop-invariant!"' failed.
</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>Windows NT
</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>max.kazantsev@azul.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Run opt -passes=unroll -S on the following IR:
; ModuleID = './simple.ll'
source_filename = "./simple.ll"
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 @pluto(i8 * %arg) #0 {
bb:
%tmp = getelementptr inbounds i8, i8 * %arg, i64 808
%tmp3 = bitcast i8 * %tmp to i64 *
%tmp4 = load atomic i64, i64 * %tmp3 unordered, align 8
%tmp5 = getelementptr inbounds i8, i8 * %arg, i64 828
%tmp6 = load atomic i8, i8 * %tmp5 unordered, align 4
br label %bb7
bb7: ; preds = %bb10, %bb
%tmp8 = phi i8 [ %tmp6, %bb ], [ %tmp20, %bb10 ]
%tmp9 = phi i64 [ %tmp4, %bb ], [ %tmp11, %bb10 ]
br label %bb12
bb10: ; preds = %bb12
%tmp11 = add i64 %tmp9, 239
store atomic i64 %tmp11, i64 * %tmp3 unordered, align 8
store atomic i8 %tmp20, i8 * %tmp5 unordered, align 4
br label %bb7
bb12: ; preds = %bb12, %bb7
%tmp13 = phi i8 [ %tmp20, %bb12 ], [ %tmp8, %bb7 ]
%tmp14 = phi i64 [ %tmp16, %bb12 ], [ %tmp9, %bb7 ]
%tmp15 = phi i64 [ %tmp21, %bb12 ], [ 2, %bb7 ]
%tmp16 = add i64 %tmp14, 1
%tmp17 = trunc i64 %tmp16 to i8
%tmp18 = mul i8 %tmp13, 100
%tmp19 = mul i8 %tmp18, %tmp13
%tmp20 = mul i8 %tmp19, %tmp17
%tmp21 = add nuw nsw i64 %tmp15, 1
%tmp22 = icmp ugt i64 %tmp15, 239
br i1 %tmp22, label %bb10, label %bb12, !prof !0
}
attributes #0 = { uwtable "target-cpu"="skylake-avx512" }
!0 = !{!"branch_weights", i32 1, i32 224}
The assertion fails like this:
opt: /home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3378: const
llvm::SCEV* llvm::ScalarEvolution::getAddRecExpr(llvm::SmallVectorImpl<const
llvm::SCEV*>&, const llvm::Loop*, llvm::SCEV::NoWrapFlags): Assertion
`isLoopInvariant(Operands[i], L) && "SCEVAddRecExpr operand is not
loop-invariant!"' failed.
Stack dump:
0. Program arguments: /home/mkazantsev/work/llvm/build/buildRA/bin/opt
-passes=unroll -S ./simple.ll
#0 0x00007f7fd6051d6a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/mkazantsev/work/llvm/lib/Support/Unix/Signals.inc:498:0
#1 0x00007f7fd604fd4a llvm::sys::RunSignalHandlers()
/home/mkazantsev/work/llvm/lib/Support/Signals.cpp:68:0
#2 0x00007f7fd604fe85 SignalHandler(int)
/home/mkazantsev/work/llvm/lib/Support/Unix/Signals.inc:357:0
#3 0x00007f7fd52c2370 __restore_rt (/lib64/libpthread.so.0+0xf370)
#4 0x00007f7fd46f71d7 __GI_raise (/lib64/libc.so.6+0x351d7)
#5 0x00007f7fd46f88c8 __GI_abort (/lib64/libc.so.6+0x368c8)
#6 0x00007f7fd46f0146 __assert_fail_base (/lib64/libc.so.6+0x2e146)
#7 0x00007f7fd46f01f2 (/lib64/libc.so.6+0x2e1f2)
#8 0x00007f7fd6fcd481
llvm::ScalarEvolution::getAddRecExpr(llvm::SmallVectorImpl<llvm::SCEV const*>&,
llvm::Loop const*, llvm::SCEV::NoWrapFlags)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3377:0
#9 0x00007f7fd6fcefb8
llvm::ScalarEvolution::getMulExpr(llvm::SmallVectorImpl<llvm::SCEV const*>&,
llvm::SCEV::NoWrapFlags, unsigned int)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3093:0
#10 0x00007f7fd6fcf49d
llvm::ScalarEvolution::getMulExpr(llvm::SmallVectorImpl<llvm::SCEV const*>&,
llvm::SCEV::NoWrapFlags, unsigned int)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3030:0
#11 0x00007f7fd6fcef98
llvm::ScalarEvolution::getMulExpr(llvm::SmallVectorImpl<llvm::SCEV const*>&,
llvm::SCEV::NoWrapFlags, unsigned int)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:2980:0
#12 0x00007f7fd6fc9cf4 llvm::SmallVectorTemplateCommon<llvm::SCEV const*,
void>::isSmall() const
/home/mkazantsev/work/llvm/include/llvm/ADT/SmallVector.h:103:0
#13 0x00007f7fd6fc9cf4 ~SmallVectorImpl
/home/mkazantsev/work/llvm/include/llvm/ADT/SmallVector.h:340:0
#14 0x00007f7fd6fc9cf4 ~SmallVector
/home/mkazantsev/work/llvm/include/llvm/ADT/SmallVector.h:852:0
#15 0x00007f7fd6fc9cf4 llvm::ScalarEvolution::createSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:6220:0
#16 0x00007f7fd6fcaa90 llvm::ScalarEvolution::getSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3923:0
#17 0x00007f7fd6fc9af5 llvm::ScalarEvolution::createSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:6211:0
#18 0x00007f7fd6fcaa90 llvm::ScalarEvolution::getSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3923:0
#19 0x00007f7fd6fc9af5 llvm::ScalarEvolution::createSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:6211:0
#20 0x00007f7fd6fcaa90 llvm::ScalarEvolution::getSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3923:0
#21 0x00007f7fd6fc9af5 llvm::ScalarEvolution::createSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:6211:0
#22 0x00007f7fd6fcaa90 llvm::ScalarEvolution::getSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3923:0
#23 0x00007f7fd6fc9af5 llvm::ScalarEvolution::createSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:6211:0
#24 0x00007f7fd6fcaa90 llvm::ScalarEvolution::getSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3923:0
#25 0x00007f7fd6fc9af5 llvm::ScalarEvolution::createSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:6211:0
#26 0x00007f7fd6fcaa90 llvm::ScalarEvolution::getSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3923:0
#27 0x00007f7fd6fc9af5 llvm::ScalarEvolution::createSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:6211:0
#28 0x00007f7fd6fcaa90 llvm::ScalarEvolution::getSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3923:0
#29 0x00007f7fd6fc8643
llvm::ScalarEvolution::createAddRecFromPHI(llvm::PHINode*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:5065:0
#30 0x00007f7fd6fc9037 llvm::ScalarEvolution::createNodeForPHI(llvm::PHINode*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:5319:0
#31 0x00007f7fd6fca5a6 llvm::ScalarEvolution::createSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:6472:0
#32 0x00007f7fd6fcaa90 llvm::ScalarEvolution::getSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3923:0
#33 0x00007f7fd6fc9cce llvm::ScalarEvolution::createSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:6214:0
#34 0x00007f7fd6fcaa90 llvm::ScalarEvolution::getSCEV(llvm::Value*)
/home/mkazantsev/work/llvm/lib/Analysis/ScalarEvolution.cpp:3923:0
#35 0x00007f7fd698b580 replaceIVUserWithLoopInvariant
/home/mkazantsev/work/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:667:0
#36 0x00007f7fd698b580 simplifyUsers
/home/mkazantsev/work/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:915:0
#37 0x00007f7fd698b580 llvm::simplifyUsersOfIV(llvm::PHINode*,
llvm::ScalarEvolution*, llvm::DominatorTree*, llvm::LoopInfo*,
llvm::SmallVectorImpl<llvm::WeakTrackingVH>&, llvm::SCEVExpander&,
llvm::IVVisitor*)
/home/mkazantsev/work/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:967:0
#38 0x00007f7fd698c671 llvm::simplifyLoopIVs(llvm::Loop*,
llvm::ScalarEvolution*, llvm::DominatorTree*, llvm::LoopInfo*,
llvm::SmallVectorImpl<llvm::WeakTrackingVH>&)
/home/mkazantsev/work/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:981:0
#39 0x00007f7fd6922b26 llvm::simplifyLoopAfterUnroll(llvm::Loop*, bool,
llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::DominatorTree*,
llvm::AssumptionCache*)
/home/mkazantsev/work/llvm/lib/Transforms/Utils/LoopUnroll.cpp:267:0
#40 0x00007f7fd6927e8b std::__atomic_base<unsigned int>::fetch_add(unsigned
int, std::memory_order) /usr/include/c++/4.8.2/bits/atomic_base.h:614:0
#41 0x00007f7fd6927e8b llvm::Statistic::operator++()
/home/mkazantsev/work/llvm/include/llvm/ADT/Statistic.h:79:0
#42 0x00007f7fd6927e8b llvm::UnrollLoop(llvm::Loop*, unsigned int, unsigned
int, bool, bool, bool, bool, bool, unsigned int, unsigned int, bool,
llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::DominatorTree*,
llvm::AssumptionCache*, llvm::OptimizationRemarkEmitter*, bool, llvm::Loop**)
/home/mkazantsev/work/llvm/lib/Transforms/Utils/LoopUnroll.cpp:835:0
#43 0x00007f7fd6bdf5f9 tryToUnrollLoop(llvm::Loop*, llvm::DominatorTree&,
llvm::LoopInfo*, llvm::ScalarEvolution&, llvm::TargetTransformInfo const&,
llvm::AssumptionCache&, llvm::OptimizationRemarkEmitter&, bool, int, bool,
llvm::Optional<unsigned int>, llvm::Optional<unsigned int>,
llvm::Optional<bool>, llvm::Optional<bool>, llvm::Optional<bool>,
llvm::Optional<bool>)
/home/mkazantsev/work/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp:1086:0
#44 0x00007f7fd6be027a llvm::LoopUnrollPass::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function<> >&)
/home/mkazantsev/work/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp:1394:0
#45 0x00007f7fd82758bd
_ZN4llvm6detail9PassModelINS_8FunctionENS_14LoopUnrollPassENS_17PreservedAnalysesENS_15AnalysisManagerIS2_IEEEIEE3runERS2_RS6_
/home/mkazantsev/work/llvm/include/llvm/IR/PassManagerInternal.h:80:0
#46 0x00007f7fd6196eef llvm::PassManager<llvm::Function,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
/home/mkazantsev/work/llvm/include/llvm/IR/PassInstrumentation.h:160:0
#47 0x00007f7fd82c8c2f
_ZN4llvm27ModuleToFunctionPassAdaptorINS_11PassManagerINS_8FunctionENS_15AnalysisManagerIS2_IEEEIEEEE3runERNS_6ModuleERNS3_IS7_IEEE
/home/mkazantsev/work/llvm/include/llvm/IR/PassManager.h:1302:0
#48 0x00007f7fd82c8c2f
_ZN4llvm6detail9PassModelINS_6ModuleENS_27ModuleToFunctionPassAdaptorINS_11PassManagerINS_8FunctionENS_15AnalysisManagerIS5_IEEEIEEEEENS_17PreservedAnalysesENS6_IS2_IEEEIEE3runERS2_RSB_
/home/mkazantsev/work/llvm/include/llvm/IR/PassManagerInternal.h:79:0
#49 0x00007f7fd61963ff llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
/home/mkazantsev/work/llvm/include/llvm/IR/PassInstrumentation.h:160:0
#50 0x000000000042bc38 llvm::runPassPipeline(llvm::StringRef, llvm::Module&,
llvm::TargetMachine*, llvm::ToolOutputFile*, llvm::ToolOutputFile*,
llvm::ToolOutputFile*, llvm::StringRef, llvm::opt_tool::OutputKind,
llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool)
/home/mkazantsev/work/llvm/tools/opt/NewPMDriver.cpp:335:0
#51 0x000000000041d6a4 main /home/mkazantsev/work/llvm/tools/opt/opt.cpp:655:0
#52 0x00007f7fd46e3b35 __libc_start_main (/lib64/libc.so.6+0x21b35)
#53 0x000000000041ee3b _start
(/home/mkazantsev/work/llvm/build/buildRA/bin/opt+0x41ee3b)
Aborted
This bug seems to be old, but I cannot say how old.</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>