Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -23167,7 +23167,13 @@ // If the input is a concat_vectors, just make a larger concat by padding // with smaller undefs. - if (In.getOpcode() == ISD::CONCAT_VECTORS && In.hasOneUse()) { + // + // Legalizing in AArch64TargetLowering::LowerCONCAT_VECTORS() and combining + // here could cause an infinite loop. That legalizing happens when LegalDAG + // is true and input of AArch64TargetLowering::LowerCONCAT_VECTORS() is + // scalable. + if (In.getOpcode() == ISD::CONCAT_VECTORS && In.hasOneUse() && + !(LegalDAG && In.getValueType().isScalableVector())) { unsigned NumOps = N->getNumOperands() * In.getNumOperands(); SmallVector Ops(In->op_begin(), In->op_end()); Ops.resize(NumOps, DAG.getUNDEF(Ops[0].getValueType())); Index: llvm/test/CodeGen/AArch64/dag-combine-concat-vectors.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/dag-combine-concat-vectors.ll @@ -0,0 +1,19 @@ +; RUN: llc -mtriple=aarch64 -mattr=+sve < %s | FileCheck %s + +; just need to check whether commands above could exit normally rather than get stuck in an +; infinite loop as described in https://github.com/llvm/llvm-project/issues/63322 and end with +; a stack dump +; +; CHECK-LABEL: allocno_reload_assign: + +declare void @llvm.masked.scatter.nxv16i8.nxv16p0(, , i32 immarg, ) + +define fastcc i8 @allocno_reload_assign() { + br label %1 + +1: ; preds = %1, %0 + call void @llvm.masked.scatter.nxv16i8.nxv16p0( zeroinitializer, zeroinitializer, i32 0, xor ( shufflevector ( icmp eq ( insertelement ( poison, ptr null, i64 0), zeroinitializer), poison, zeroinitializer), shufflevector ( insertelement ( poison, i1 true, i32 0), poison, zeroinitializer))) + br label %1 +} + +uselistorder poison, { 1, 2, 0 }