From 331e1c2a0e1efdff119720de9bd7bc010e3f3642 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Fri, 20 Jun 2025 19:39:57 -0400 Subject: [PATCH] SROA generate a noundef instead of splatting a noundef int --- llvm/lib/Transforms/Scalar/SROA.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index 42d1d9a437bb2..028bcde5a51d7 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -3221,12 +3221,16 @@ class AllocaSliceRewriter : public InstVisitor { return V; Type *SplatIntTy = Type::getIntNTy(VTy->getContext(), Size * 8); - V = IRB.CreateMul( - IRB.CreateZExt(V, SplatIntTy, "zext"), - IRB.CreateUDiv(Constant::getAllOnesValue(SplatIntTy), - IRB.CreateZExt(Constant::getAllOnesValue(V->getType()), - SplatIntTy)), - "isplat"); + if (isa(V)) { + V = UndefValue::get(VTy); + } else { + V = IRB.CreateMul( + IRB.CreateZExt(V, SplatIntTy, "zext"), + IRB.CreateUDiv(Constant::getAllOnesValue(SplatIntTy), + IRB.CreateZExt(Constant::getAllOnesValue(V->getType()), + SplatIntTy)), + "isplat"); + } return V; }