Skip to content

Commit 331e1c2

Browse files
committed
SROA generate a noundef instead of splatting a noundef int
1 parent 8d2eea9 commit 331e1c2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,12 +3221,16 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
32213221
return V;
32223222

32233223
Type *SplatIntTy = Type::getIntNTy(VTy->getContext(), Size * 8);
3224-
V = IRB.CreateMul(
3225-
IRB.CreateZExt(V, SplatIntTy, "zext"),
3226-
IRB.CreateUDiv(Constant::getAllOnesValue(SplatIntTy),
3227-
IRB.CreateZExt(Constant::getAllOnesValue(V->getType()),
3228-
SplatIntTy)),
3229-
"isplat");
3224+
if (isa<UndefValue>(V)) {
3225+
V = UndefValue::get(VTy);
3226+
} else {
3227+
V = IRB.CreateMul(
3228+
IRB.CreateZExt(V, SplatIntTy, "zext"),
3229+
IRB.CreateUDiv(Constant::getAllOnesValue(SplatIntTy),
3230+
IRB.CreateZExt(Constant::getAllOnesValue(V->getType()),
3231+
SplatIntTy)),
3232+
"isplat");
3233+
}
32303234
return V;
32313235
}
32323236

0 commit comments

Comments
 (0)