diff --git a/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp b/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp --- a/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp +++ b/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp @@ -481,6 +481,15 @@ if (isa(I->getArgOperand(0))) return processPhiNode(I); + if (auto *C = dyn_cast(I->getArgOperand(0))) { + if (!C->isNullValue()) + return false; + + I->replaceAllUsesWith(ConstantInt::getFalse(I->getType())); + I->eraseFromParent(); + return true; + } + SmallVector CandidatesForRemoval; Value *Cursor = I->getOperand(0), *EarliestReplacement = nullptr; diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll b/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll --- a/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll @@ -251,6 +251,13 @@ ret %pg } +define @reinterpret_zero() { +; OPT-LABEL: @reinterpret_zero( +; OPT: ret zeroinitializer + %pg = tail call @llvm.aarch64.sve.convert.from.svbool.nxv2i1( zeroinitializer) + ret %pg +} + declare @llvm.aarch64.sve.convert.to.svbool.nxv8i1() declare @llvm.aarch64.sve.convert.to.svbool.nxv4i1() declare @llvm.aarch64.sve.convert.to.svbool.nxv2i1()