Issue 76734
Summary Assertion `N1.getValueType().bitsGT(VT) && "Invalid truncate node, src < dst!"' failed.
Labels backend:AArch64, crash-on-valid
Assignees
Reporter regehr
    I'm getting a crash from codegen on this input:
```llvm
define void @f(ptr %0, <4 x i16> %1) {
  %3 = zext <4 x i16> %1 to <4 x i32>
  %4 = add <4 x i32> %3, <i32 1, i32 1, i32 1, i32 1>
  %5 = trunc <4 x i32> %4 to <4 x i19>
  %new0 = add <4 x i19> %5, <i19 1, i19 1, i19 1, i19 1>
  %new1 = lshr <4 x i19> %new0, <i19 1, i19 1, i19 1, i19 1>
  %last = zext <4 x i19> %new1 to <4 x i32>
  %6 = trunc <4 x i32> %last to <4 x i16>
 store <4 x i16> %6, ptr %0, align 4
  ret void
}
```

```
regehr@john-home:~/test/assertion-fail$ ~/llvm-project/for-alive/bin/llc test-229001578104.ll -march=aarch64 
llc: /home/regehr/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5781: llvm::SDValue llvm::SelectionDAG::getNode(unsigned int, const llvm::SDLoc&, llvm::EVT, llvm::SDValue, llvm::SDNodeFlags): Assertion `N1.getValueType().bitsGT(VT) && "Invalid truncate node, src < dst!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/regehr/llvm-project/for-alive/bin/llc test-229001578104.ll -march=aarch64
1.	Running pass 'Function Pass Manager' on module 'test-229001578104.ll'.
2.	Running pass 'AArch64 Instruction Selection' on function '@f'
 #0 0x00007f9c97c012a0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSupport.so.18git+0x2012a0)
 #1 0x00007f9c97bfe2af llvm::sys::RunSignalHandlers() (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSupport.so.18git+0x1fe2af)
 #2 0x00007f9c97bfe405 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f9c97242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f9c972969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f9c972969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f9c972969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f9c97242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f9c972287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f9c9722871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f9c97239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007f9c9a7529d5 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDNodeFlags) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSelectionDAG.so.18git+0x3529d5)
#12 0x00007f9c9a7bf114 combineShiftToAVG(llvm::SDValue, llvm::SelectionDAG&, llvm::TargetLowering const&, llvm::APInt const&, llvm::APInt const&, unsigned int) (.isra.0) TargetLowering.cpp:0:0
#13 0x00007f9c9a7f4780 llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&, llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSelectionDAG.so.18git+0x3f4780)
#14 0x00007f9c9a7f5a66 llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&, llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSelectionDAG.so.18git+0x3f5a66)
#15 0x00007f9c9a80017a llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSelectionDAG.so.18git+0x40017a)
#16 0x00007f9c9a4d7e61 (anonymous namespace)::DAGCombiner::SimplifyDemandedBits(llvm::SDValue) (.constprop.0) DAGCombiner.cpp:0:0
#17 0x00007f9c9a521084 (anonymous namespace)::DAGCombiner::visitTRUNCATE(llvm::SDNode*) DAGCombiner.cpp:0:0
#18 0x00007f9c9a548a15 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#19 0x00007f9c9a54a6ed llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOptLevel) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSelectionDAG.so.18git+0x14a6ed)
#20 0x00007f9c9a79371b llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSelectionDAG.so.18git+0x39371b)
#21 0x00007f9c9a7975d2 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSelectionDAG.so.18git+0x3975d2)
#22 0x00007f9c9a799297 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSelectionDAG.so.18git+0x399297)
#23 0x00007f9c99c0d602 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMCodeGen.so.18git+0x40d602)
#24 0x00007f9c980d8006 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMCore.so.18git+0x2d8006)
#25 0x00007f9c980d8249 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMCore.so.18git+0x2d8249)
#26 0x00007f9c980d8ae2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMCore.so.18git+0x2d8ae2)
#27 0x00005643f03bfbd1 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#28 0x00005643f03b433c main (/home/regehr/llvm-project/for-alive/bin/llc+0x1333c)
#29 0x00007f9c97229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#30 0x00007f9c97229e40 call_init ./csu/../csu/libc-start.c:128:20
#31 0x00007f9c97229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#32 0x00005643f03b4845 _start (/home/regehr/llvm-project/for-alive/bin/llc+0x13845)
Aborted (core dumped)
regehr@john-home:~/test/assertion-fail$ 
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to