[llvm-bugs] [Bug 48725] New: [LSR] Crash during CompareSCEVComplexity on unrolled loop

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 12 00:05:41 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=48725

            Bug ID: 48725
           Summary: [LSR] Crash during CompareSCEVComplexity on unrolled
                    loop
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: max.kazantsev at azul.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Run opt -loop-reduce -S on the following test:

```

source_filename = "./simple.ll"
target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
target triple = "x86_64-unknown-linux-gnu"

define void @test() {
bb:
  br label %bb1

bb1:                                              ; preds = %bb1, %bb
  %tmp = phi i32 [ undef, %bb ], [ %tmp87, %bb1 ]
  %tmp2 = phi i32 [ undef, %bb ], [ %tmp86, %bb1 ]
  %tmp3 = mul i32 %tmp, undef
  %tmp4 = xor i32 %tmp3, -1
  %tmp5 = add i32 %tmp, %tmp4
  %tmp6 = add i32 %tmp2, -1
  %tmp7 = add i32 %tmp5, %tmp6
  %tmp8 = mul i32 %tmp7, %tmp3
  %tmp9 = xor i32 %tmp8, -1
  %tmp10 = add i32 %tmp7, %tmp9
  %tmp11 = add i32 %tmp10, undef
  %tmp12 = mul i32 %tmp11, %tmp8
  %tmp13 = xor i32 %tmp12, -1
  %tmp14 = add i32 %tmp11, %tmp13
  %tmp15 = add i32 %tmp14, undef
  %tmp16 = mul i32 %tmp15, %tmp12
  %tmp17 = add i32 %tmp15, undef
  %tmp18 = add i32 %tmp17, undef
  %tmp19 = mul i32 %tmp18, %tmp16
  %tmp20 = xor i32 %tmp19, -1
  %tmp21 = add i32 %tmp18, %tmp20
  %tmp22 = add i32 %tmp21, undef
  %tmp23 = mul i32 %tmp22, %tmp19
  %tmp24 = xor i32 %tmp23, -1
  %tmp25 = add i32 %tmp22, %tmp24
  %tmp26 = add i32 %tmp25, undef
  %tmp27 = mul i32 %tmp26, %tmp23
  %tmp28 = xor i32 %tmp27, -1
  %tmp29 = add i32 %tmp26, %tmp28
  %tmp30 = add i32 %tmp29, undef
  %tmp31 = mul i32 %tmp30, %tmp27
  %tmp32 = xor i32 %tmp31, -1
  %tmp33 = add i32 %tmp30, %tmp32
  %tmp34 = add i32 %tmp33, undef
  %tmp35 = mul i32 %tmp34, %tmp31
  %tmp36 = xor i32 %tmp35, -1
  %tmp37 = add i32 %tmp34, %tmp36
  %tmp38 = add i32 %tmp2, -9
  %tmp39 = add i32 %tmp37, %tmp38
  %tmp40 = mul i32 %tmp39, %tmp35
  %tmp41 = xor i32 %tmp40, -1
  %tmp42 = add i32 %tmp39, %tmp41
  %tmp43 = add i32 %tmp42, undef
  %tmp44 = mul i32 %tmp43, %tmp40
  %tmp45 = xor i32 %tmp44, -1
  %tmp46 = add i32 %tmp43, %tmp45
  %tmp47 = add i32 %tmp46, undef
  %tmp48 = mul i32 %tmp47, %tmp44
  %tmp49 = xor i32 %tmp48, -1
  %tmp50 = add i32 %tmp47, %tmp49
  %tmp51 = add i32 %tmp50, undef
  %tmp52 = mul i32 %tmp51, %tmp48
  %tmp53 = xor i32 %tmp52, -1
  %tmp54 = add i32 %tmp51, %tmp53
  %tmp55 = add i32 %tmp54, undef
  %tmp56 = mul i32 %tmp55, %tmp52
  %tmp57 = xor i32 %tmp56, -1
  %tmp58 = add i32 %tmp55, %tmp57
  %tmp59 = add i32 %tmp2, -14
  %tmp60 = add i32 %tmp58, %tmp59
  %tmp61 = mul i32 %tmp60, %tmp56
  %tmp62 = xor i32 %tmp61, -1
  %tmp63 = add i32 %tmp60, %tmp62
  %tmp64 = add i32 %tmp63, undef
  %tmp65 = mul i32 %tmp64, %tmp61
  %tmp66 = xor i32 %tmp65, -1
  %tmp67 = add i32 %tmp64, %tmp66
  %tmp68 = add i32 %tmp67, undef
  %tmp69 = mul i32 %tmp68, %tmp65
  %tmp70 = xor i32 %tmp69, -1
  %tmp71 = add i32 %tmp68, %tmp70
  %tmp72 = add i32 %tmp71, undef
  %tmp73 = mul i32 %tmp72, %tmp69
  %tmp74 = xor i32 %tmp73, -1
  %tmp75 = add i32 %tmp72, %tmp74
  %tmp76 = add i32 %tmp75, undef
  %tmp77 = mul i32 %tmp76, %tmp73
  %tmp78 = xor i32 %tmp77, -1
  %tmp79 = add i32 %tmp76, %tmp78
  %tmp80 = add i32 %tmp79, undef
  %tmp81 = mul i32 %tmp80, %tmp77
  %tmp82 = xor i32 %tmp81, -1
  %tmp83 = add i32 %tmp80, %tmp82
  %tmp84 = add i32 %tmp83, undef
  %tmp85 = add i32 %tmp84, undef
  %tmp86 = add i32 %tmp2, -21
  %tmp87 = add i32 %tmp85, %tmp86
  br label %bb1
}


```

Crashes as follows:

PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0.      Program arguments: /localhome/mkazantsev/work/llvm/build/RA/bin/opt
-loop-reduce -S ./reduced.ll
1.      Running pass 'Function Pass Manager' on module './reduced.ll'.
2.      Running pass 'Loop Pass Manager' on function '@test'
3.      Running pass 'Loop Strength Reduction' on basic block '%bb1'
 #0 0x0000000002923b1c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Support/Unix/Signals.inc:567:0
 #1 0x0000000002921924 llvm::sys::RunSignalHandlers()
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Support/Signals.cpp:71:0
 #2 0x000000000292222d SignalHandler(int)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Support/Unix/Signals.inc:405:0
 #3 0x00007f6db1178630 __restore_rt (/lib64/libpthread.so.0+0xf630)
 #4 0x0000000001b01626
CompareSCEVComplexity(llvm::EquivalenceClasses<llvm::SCEV const*>&,
llvm::EquivalenceClasses<llvm::Value const*>&, llvm::LoopInfo const*,
llvm::SCEV const*, llvm::SCEV const*, llvm::DominatorTree&, unsigned int)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Analysis/ScalarEvolution.cpp:701:0
 #5 0x0000000001b01f4f __unguarded_linear_insert<const llvm::SCEV**,
__gnu_cxx::__ops::_Val_comp_iter<GroupByComplexity(llvm::SmallVectorImpl<const
llvm::SCEV*>&, llvm::LoopInfo*, llvm::DominatorTree&)::<lambda(const
llvm::SCEV*, const llvm::SCEV*)> > >
/home/buildmaster/sw/centaurea/gcc-7.4.0-rhel6/include/c++/7.4.0/bits/stl_algo.h:1828:0
 #6 0x0000000001b01f4f void std::__insertion_sort<llvm::SCEV const**,
__gnu_cxx::__ops::_Iter_comp_iter<GroupByComplexity(llvm::SmallVectorImpl<llvm::SCEV
const*>&, llvm::LoopInfo*, llvm::DominatorTree&)::'lambda'(llvm::SCEV const*,
llvm::SCEV const*)> >(llvm::SCEV const**, llvm::SCEV const**,
__gnu_cxx::__ops::_Iter_comp_iter<GroupByComplexity(llvm::SmallVectorImpl<llvm::SCEV
const*>&, llvm::LoopInfo*, llvm::DominatorTree&)::'lambda'(llvm::SCEV const*,
llvm::SCEV const*)>)
/home/buildmaster/sw/centaurea/gcc-7.4.0-rhel6/include/c++/7.4.0/bits/stl_algo.h:1855:0
 #7 0x0000000001b01ffc __chunk_insertion_sort<const llvm::SCEV**, long int,
__gnu_cxx::__ops::_Iter_comp_iter<GroupByComplexity(llvm::SmallVectorImpl<const
llvm::SCEV*>&, llvm::LoopInfo*, llvm::DominatorTree&)::<lambda(const
llvm::SCEV*, const llvm::SCEV*)> > >
/home/buildmaster/sw/centaurea/gcc-7.4.0-rhel6/include/c++/7.4.0/bits/stl_algo.h:2693:0
 #8 0x0000000001b01ffc void std::__merge_sort_with_buffer<llvm::SCEV const**,
llvm::SCEV const**,
__gnu_cxx::__ops::_Iter_comp_iter<GroupByComplexity(llvm::SmallVectorImpl<llvm::SCEV
const*>&, llvm::LoopInfo*, llvm::DominatorTree&)::'lambda'(llvm::SCEV const*,
llvm::SCEV const*)> >(llvm::SCEV const**, llvm::SCEV const**, llvm::SCEV
const**,
__gnu_cxx::__ops::_Iter_comp_iter<GroupByComplexity(llvm::SmallVectorImpl<llvm::SCEV
const*>&, llvm::LoopInfo*, llvm::DominatorTree&)::'lambda'(llvm::SCEV const*,
llvm::SCEV const*)>)
/home/buildmaster/sw/centaurea/gcc-7.4.0-rhel6/include/c++/7.4.0/bits/stl_algo.h:2716:0
 #9 0x0000000001b0cd95 void std::__stable_sort_adaptive<llvm::SCEV const**,
llvm::SCEV const**, long,
__gnu_cxx::__ops::_Iter_comp_iter<GroupByComplexity(llvm::SmallVectorImpl<llvm::SCEV
const*>&, llvm::LoopInfo*, llvm::DominatorTree&)::'lambda'(llvm::SCEV const*,
llvm::SCEV const*)> >(llvm::SCEV const**, llvm::SCEV const**, llvm::SCEV
const**, long,
__gnu_cxx::__ops::_Iter_comp_iter<GroupByComplexity(llvm::SmallVectorImpl<llvm::SCEV
const*>&, llvm::LoopInfo*, llvm::DominatorTree&)::'lambda'(llvm::SCEV const*,
llvm::SCEV const*)>)
/home/buildmaster/sw/centaurea/gcc-7.4.0-rhel6/include/c++/7.4.0/bits/stl_algo.h:2749:0
#10 0x0000000001b0d34f __stable_sort<const llvm::SCEV**,
__gnu_cxx::__ops::_Iter_comp_iter<GroupByComplexity(llvm::SmallVectorImpl<const
llvm::SCEV*>&, llvm::LoopInfo*, llvm::DominatorTree&)::<lambda(const
llvm::SCEV*, const llvm::SCEV*)> > >
/home/buildmaster/sw/centaurea/gcc-7.4.0-rhel6/include/c++/7.4.0/bits/stl_algo.h:5008:0
#11 0x0000000001b0d34f stable_sort<const llvm::SCEV**,
GroupByComplexity(llvm::SmallVectorImpl<const llvm::SCEV*>&, llvm::LoopInfo*,
llvm::DominatorTree&)::<lambda(const llvm::SCEV*, const llvm::SCEV*)> >
/home/buildmaster/sw/centaurea/gcc-7.4.0-rhel6/include/c++/7.4.0/bits/stl_algo.h:5077:0
#12 0x0000000001b0d34f stable_sort<llvm::SmallVectorImpl<const llvm::SCEV*>&,
GroupByComplexity(llvm::SmallVectorImpl<const llvm::SCEV*>&, llvm::LoopInfo*,
llvm::DominatorTree&)::<lambda(const llvm::SCEV*, const llvm::SCEV*)> >
/localhome/mkazantsev/work/llvm/llvm/llvm/include/llvm/ADT/STLExtras.h:1639:0
#13 0x0000000001b0d34f GroupByComplexity(llvm::SmallVectorImpl<llvm::SCEV
const*>&, llvm::LoopInfo*, llvm::DominatorTree&)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Analysis/ScalarEvolution.cpp:859:0
#14 0x0000000001b1fb67 llvm::SmallVectorTemplateCommon<llvm::SCEV const*,
void>::operator[](unsigned long)
/localhome/mkazantsev/work/llvm/llvm/llvm/include/llvm/ADT/SmallVector.h:246:0
#15 0x0000000001b1fb67
llvm::ScalarEvolution::getAddExpr(llvm::SmallVectorImpl<llvm::SCEV const*>&,
llvm::SCEV::NoWrapFlags, unsigned int)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Analysis/ScalarEvolution.cpp:2296:0
#16 0x00000000027288f1 initialMatch
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:461:0
#17 0x00000000027288f1 InsertInitialFormula
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:3350:0
#18 0x00000000027288f1 (anonymous
namespace)::LSRInstance::CollectFixupsAndInitialFormulae()
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:3333:0
#19 0x0000000002738603 LSRInstance
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5651:0
#20 0x0000000002738603 ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&,
llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&,
llvm::TargetTransformInfo const&, llvm::AssumptionCache&,
llvm::TargetLibraryInfo&, llvm::MemorySSA*)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5857:0
#21 0x00000000027398a1 (anonymous
namespace)::LoopStrengthReduce::runOnLoop(llvm::Loop*, llvm::LPPassManager&)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5905:0
#22 0x0000000001a65553 llvm::LPPassManager::runOnFunction(llvm::Function&)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/Analysis/LoopPass.cpp:198:0
#23 0x000000000219bfdb llvm::FPPassManager::runOnFunction(llvm::Function&)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/IR/LegacyPassManager.cpp:1450:0
#24 0x000000000219ca29
llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true,
false, void> >::getNext()
/localhome/mkazantsev/work/llvm/llvm/llvm/include/llvm/ADT/ilist_node.h:66:0
#25 0x000000000219ca29
llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true,
false, void>, false, false>::operator++()
/localhome/mkazantsev/work/llvm/llvm/llvm/include/llvm/ADT/ilist_iterator.h:157:0
#26 0x000000000219ca29 llvm::FPPassManager::runOnModule(llvm::Module&)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/IR/LegacyPassManager.cpp:1485:0
#27 0x000000000219b90e runOnModule
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/IR/LegacyPassManager.cpp:1562:0
#28 0x000000000219b90e llvm::legacy::PassManagerImpl::run(llvm::Module&)
/localhome/mkazantsev/work/llvm/llvm/llvm/lib/IR/LegacyPassManager.cpp:542:0
#29 0x00000000007299ca main
/localhome/mkazantsev/work/llvm/llvm/llvm/tools/opt/opt.cpp:1021:0
#30 0x00007f6dafcc0555 __libc_start_main (/lib64/libc.so.6+0x22555)
#31 0x00000000007d5589 _start
(/localhome/mkazantsev/work/llvm/build/RA/bin/opt+0x7d5589)
Segmentation fault (core dumped)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210112/91af45ea/attachment-0001.html>


More information about the llvm-bugs mailing list