Skip to content

[SDAG][X86] Assertion `(Inputs.size() == 1 || Inputs.size() == 2) && "Unexpected number of shuffle inputs!"' failed. #158415

@XChy

Description

@XChy

Testcase:

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define <32 x i16> @func_10(<8 x i8> %0) #0 {
entry:
  %shuffle2 = shufflevector <8 x i8> %0, <8 x i8> zeroinitializer, <32 x i32> <i32 2, i32 2, i32 9, i32 3, i32 1, i32 0, i32 0, i32 2, i32 0, i32 5, i32 9, i32 6, i32 5, i32 4, i32 7, i32 2, i32 7, i32 9, i32 4, i32 0, i32 9, i32 2, i32 4, i32 3, i32 3, i32 2, i32 2, i32 3, i32 9, i32 0, i32 6, i32 4>
  %conv3 = zext <32 x i8> %shuffle2 to <32 x i16>
  %shuffle4 = shufflevector <32 x i16> zeroinitializer, <32 x i16> %conv3, <32 x i32> <i32 5, i32 3, i32 4, i32 47, i32 5, i32 5, i32 3, i32 63, i32 4, i32 4, i32 60, i32 2, i32 2, i32 5, i32 4, i32 0, i32 38, i32 1, i32 0, i32 3, i32 59, i32 2, i32 3, i32 1, i32 1, i32 0, i32 3, i32 34, i32 0, i32 0, i32 62, i32 5>
  %not = xor <32 x i16> %shuffle4, splat (i16 1)
  %shuffle5 = shufflevector <32 x i16> zeroinitializer, <32 x i16> %not, <32 x i32> <i32 3, i32 9, i32 3, i32 1, i32 9, i32 8, i32 9, i32 2, i32 0, i32 8, i32 48, i32 8, i32 35, i32 3, i32 0, i32 4, i32 4, i32 7, i32 4, i32 39, i32 9, i32 0, i32 59, i32 6, i32 0, i32 4, i32 9, i32 1, i32 1, i32 2, i32 8, i32 9>
  ret <32 x i16> %shuffle5
}

attributes #0 = { "target-features"="+avx2" }

Compiler stderr:

llc: /root/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:39962: llvm::SDValue combineX86ShuffleChain(llvm::ArrayRef<llvm::SDValue>, unsigned int, llvm::MVT, llvm::ArrayRef<int>, int, llvm::ArrayRef<const llvm::SDNode*>, bool, bool, bool, llvm::SelectionDAG&, const llvm::SDLoc&, const llvm::X86Subtarget&): Assertion `(Inputs.size() == 1 || Inputs.size() == 2) && "Unexpected number of shuffle inputs!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -O0 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@func_10'
 #0 0x00000000040d8cf8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x40d8cf8)
 #1 0x00000000040d5ba4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x000072bf14a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000072bf14a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x000072bf14a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x000072bf14a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x000072bf14a2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x000072bf14a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x00000000023467e7 combineX86ShuffleChain(llvm::ArrayRef<llvm::SDValue>, unsigned int, llvm::MVT, llvm::ArrayRef<int>, int, llvm::ArrayRef<llvm::SDNode const*>, bool, bool, bool, llvm::SelectionDAG&, llvm::SDLoc const&, llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
 #9 0x00000000023f0e12 combineX86ShufflesRecursively(llvm::ArrayRef<llvm::SDValue>, int, unsigned int, llvm::MVT, llvm::ArrayRef<int>, llvm::ArrayRef<llvm::SDNode const*>, unsigned int, unsigned int, bool, bool, bool, llvm::SelectionDAG&, llvm::SDLoc const&, llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#10 0x00000000023ef7b2 combineX86ShufflesRecursively(llvm::ArrayRef<llvm::SDValue>, int, unsigned int, llvm::MVT, llvm::ArrayRef<int>, llvm::ArrayRef<llvm::SDNode const*>, unsigned int, unsigned int, bool, bool, bool, llvm::SelectionDAG&, llvm::SDLoc const&, llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#11 0x00000000023ef7b2 combineX86ShufflesRecursively(llvm::ArrayRef<llvm::SDValue>, int, unsigned int, llvm::MVT, llvm::ArrayRef<int>, llvm::ArrayRef<llvm::SDNode const*>, unsigned int, unsigned int, bool, bool, bool, llvm::SelectionDAG&, llvm::SDLoc const&, llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#12 0x00000000023ef7b2 combineX86ShufflesRecursively(llvm::ArrayRef<llvm::SDValue>, int, unsigned int, llvm::MVT, llvm::ArrayRef<int>, llvm::ArrayRef<llvm::SDNode const*>, unsigned int, unsigned int, bool, bool, bool, llvm::SelectionDAG&, llvm::SDLoc const&, llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#13 0x00000000023ef7b2 combineX86ShufflesRecursively(llvm::ArrayRef<llvm::SDValue>, int, unsigned int, llvm::MVT, llvm::ArrayRef<int>, llvm::ArrayRef<llvm::SDNode const*>, unsigned int, unsigned int, bool, bool, bool, llvm::SelectionDAG&, llvm::SDLoc const&, llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#14 0x00000000023f7a8e llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(llvm::SDValue, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x23f7a8e)
#15 0x0000000003ee7025 llvm::TargetLowering::SimplifyDemandedVectorElts(llvm::SDValue, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3ee7025)
#16 0x00000000023f781b llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(llvm::SDValue, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x23f781b)
#17 0x0000000003ee7025 llvm::TargetLowering::SimplifyDemandedVectorElts(llvm::SDValue, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3ee7025)
#18 0x0000000003ee75ee llvm::TargetLowering::SimplifyDemandedVectorElts(llvm::SDValue, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3ee75ee)
#19 0x00000000023f781b llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(llvm::SDValue, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x23f781b)
#20 0x0000000003ee7025 llvm::TargetLowering::SimplifyDemandedVectorElts(llvm::SDValue, llvm::APInt const&, llvm::APInt&, llvm::APInt&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3ee7025)
#21 0x0000000003ee83ae llvm::TargetLowering::SimplifyDemandedVectorElts(llvm::SDValue, llvm::APInt const&, llvm::TargetLowering::DAGCombinerInfo&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3ee83ae)
#22 0x000000000240fdc9 combineShuffle(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#23 0x0000000002411ad5 llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2411ad5)
#24 0x0000000003d04ac1 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#25 0x0000000003d064bd (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0
#26 0x0000000003d09023 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::BatchAAResults*, llvm::CodeGenOptLevel) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3d09023)
#27 0x0000000003e71bbd llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3e71bbd)
#28 0x0000000003e752bd llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3e752bd)
#29 0x0000000003e768a5 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3e768a5)
#30 0x0000000003e6209f llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3e6209f)
#31 0x0000000002ff0719 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#32 0x00000000036277e8 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36277e8)
#33 0x0000000003627a21 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3627a21)
#34 0x000000000362828f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x362828f)
#35 0x00000000008eb1bd compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#36 0x00000000007bc346 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7bc346)
#37 0x000072bf14a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#38 0x000072bf14a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#39 0x00000000008e1615 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x8e1615)
Program terminated with signal: SIGSEGV

The crash can be reproduced since 21.1.0.
Reproducer:https://godbolt.org/z/6vxWszqo7

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions