Skip to content

Assertion hiBit <= BitWidth && "hiBit out of range" failed. #155762

@abhishek-kaushik22

Description

@abhishek-kaushik22

The assertion is hit when trying to compile this piece of IR

define <8 x i1> @i8_mask_extract_8(i8 %mask) {
  %.splatinsert = insertelement <8 x i8> poison, i8 %mask, i64 0
  %.splat = shufflevector <8 x i8> %.splatinsert, <8 x i8> poison, <8 x i32> zeroinitializer
  %1 = and <8 x i8> %.splat, <i8 2, i8 4, i8 8, i8 16, i8 32, i8 64, i8 128, i8 poison>
  %cmp.45 = icmp ne <8 x i8> %1, zeroinitializer
  ret <8 x i1> %cmp.45
}

Godbolt: https://godbolt.org/z/ahvf5dMcq

llc: /root/llvm-project/llvm/include/llvm/ADT/APInt.h:1368: void llvm::APInt::setBits(unsigned int, unsigned int): Assertion `hiBit <= BitWidth && "hiBit out of range"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mcpu=x86-64-v4 -debug <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@i8_mask_extract_8'
 #0 0x0000000003f7b3b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3f7b3b8)
 #1 0x0000000003f78264 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007cec2cc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007cec2cc969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007cec2cc42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007cec2cc287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007cec2cc2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007cec2cc39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x0000000000d20778 (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xd20778)
 #9 0x000000000239f592 combineSetCC(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#10 0x00000000023fb0b2 llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x23fb0b2)
#11 0x0000000003baddd1 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#12 0x0000000003baf6e0 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0
#13 0x0000000003bb1863 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::BatchAAResults*, llvm::CodeGenOptLevel) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3bb1863)
#14 0x0000000003d174bd llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3d174bd)
#15 0x0000000003d1aa0d llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3d1aa0d)
#16 0x0000000003d1be45 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3d1be45)
#17 0x0000000003d075ef llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3d075ef)
#18 0x0000000002ec2359 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#19 0x00000000034e719c llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x34e719c)
#20 0x00000000034e7561 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x34e7561)
#21 0x00000000034e7dcb llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x34e7dcb)
#22 0x00000000008eac9d compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#23 0x00000000007ba91e main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7ba91e)
#24 0x00007cec2cc29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#25 0x00007cec2cc29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#26 0x00000000008e1125 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x8e1125)
Program terminated with signal: SIGSEGV
Compiler returned: 139

This is a regression from the previous release and the guilty commit is 17857d9.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions